From a0c136a0c23998b4a66679d1d8883ee057ef5060 Mon Sep 17 00:00:00 2001 From: "vandebo@chromium.org" Date: Sat, 25 Feb 2012 06:28:56 +0000 Subject: Improve SharedMemory::Lock on Posix and reenable StatsTableTest.MultipleThreads BUG=10611 TEST=NONE Review URL: http://codereview.chromium.org/9463018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123647 0039d316-1c4b-4281-b951-d872f2087c98 --- base/shared_memory.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'base/shared_memory.h') diff --git a/base/shared_memory.h b/base/shared_memory.h index 298baa6..a5744830 100644 --- a/base/shared_memory.h +++ b/base/shared_memory.h @@ -8,18 +8,22 @@ #include "build/build_config.h" +#include + #if defined(OS_POSIX) #include #include #include -#include "base/file_descriptor_posix.h" #endif -#include #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) -- cgit v1.1