Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4005)

Unified Diff: base/shared_memory.h

Issue 9463018: Improve SharedMemory::Lock on Posix and reenable StatsTableTest.MultipleThreads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change to global variable Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/shared_memory.h
diff --git a/base/shared_memory.h b/base/shared_memory.h
index 8cb27ecd2ee4bd8caf7db337dfe4cd56e96420d0..2766bbb1fd904ddebc96d29158f6eac45f2151b3 100644
--- a/base/shared_memory.h
+++ b/base/shared_memory.h
@@ -8,17 +8,21 @@
#include "build/build_config.h"
+#include <string>
+
#if defined(OS_POSIX)
#include <sys/types.h>
#include <semaphore.h>
-#include "base/file_descriptor_posix.h"
#endif
-#include <string>
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/process.h"
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
+#endif
+
class FilePath;
namespace base {
@@ -202,12 +206,11 @@ class BASE_EXPORT SharedMemory {
// Locks the shared memory.
// This is a cross-process lock which may be recursively
// locked by the same thread.
- // TODO(port):
- // WARNING: on POSIX the lock only works across processes, not
- // across threads. 2 threads in the same process can both grab the
- // lock at the same time. There are several solutions for this
- // (futex, lockf+anon_semaphore) but none are both clean and common
- // across Mac and Linux.
+ //
+ // WARNING: on POSIX the memory locking primitive only works across
+ // processes, not across threads. The Lock method is not currently
+ // used in inner loops, so we protect against multiple threads in a
+ // critical section using a class global lock.
jar (doing other things) 2012/02/25 00:01:39 Since a class-global-lock probably does not allow
vandebo (ex-Chrome) 2012/02/25 01:50:36 Done.
void Lock();
#if defined(OS_WIN)

Powered by Google App Engine
This is Rietveld 408576698