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

Unified Diff: base/shared_memory_posix.cc

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
« base/shared_memory.h ('K') | « base/shared_memory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/shared_memory_posix.cc
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 32a55e91284f21d5abc299e376dd81192f668d4e..e424ad1fcd326fc50bac46f59f58b3f410940c40 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -11,9 +11,11 @@
#include <unistd.h>
#include "base/file_util.h"
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/threading/platform_thread.h"
#include "base/safe_strerror_posix.h"
+#include "base/synchronization/lock.h"
#include "base/threading/thread_restrictions.h"
#include "base/utf_string_conversions.h"
@@ -34,6 +36,8 @@ namespace {
// namespaces, but who knows what's out there.
const char kSemaphoreSuffix[] = "-sem";
+LazyInstance<Lock> g_thread_lock_ = LAZY_INSTANCE_INITIALIZER;
jar (doing other things) 2012/02/25 00:01:39 Should this be a leaky lazy instance? Are you sur
vandebo (ex-Chrome) 2012/02/25 01:50:36 Good point - The existing uses *might* be ok to us
+
}
SharedMemory::SharedMemory()
@@ -268,11 +272,13 @@ void SharedMemory::Close() {
}
void SharedMemory::Lock() {
+ g_thread_lock_.Get().Acquire();
LockOrUnlockCommon(F_LOCK);
}
void SharedMemory::Unlock() {
LockOrUnlockCommon(F_ULOCK);
+ g_thread_lock_.Get().Release();
}
#if !defined(OS_ANDROID)
« base/shared_memory.h ('K') | « base/shared_memory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698