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

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: Rebase 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
« no previous file with comments | « base/metrics/stats_table_unittest.cc ('k') | base/shared_memory_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/shared_memory.h
diff --git a/base/shared_memory.h b/base/shared_memory.h
index 298baa6cd46110c12c7d59ff846d688b12e55b3c..a5744830c65bc80435d2b0285dc4ee0702c339b3 100644
--- a/base/shared_memory.h
+++ b/base/shared_memory.h
@@ -8,18 +8,22 @@
#include "build/build_config.h"
+#include <string>
+
#if defined(OS_POSIX)
#include <stdio.h>
#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 {
@@ -201,14 +205,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.
void Lock();
#if defined(OS_WIN)
« no previous file with comments | « base/metrics/stats_table_unittest.cc ('k') | base/shared_memory_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698