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

Unified Diff: third_party/re2/util/mutex.h

Issue 10873029: Migrate WebRequestRedirectByRegExAction to use RE2 and roll RE2 to revision 97:401ab4168e8e (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 8 years, 4 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 | « third_party/re2/util/logging.h ('k') | third_party/re2/util/sparse_array.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/util/mutex.h
diff --git a/third_party/re2/util/mutex.h b/third_party/re2/util/mutex.h
index 4bb6fecc54002fc7b099a1f8c1ecdc33b49d077b..e321fae7360e036dfb7eee510e61cdb9d6e760c1 100644
--- a/third_party/re2/util/mutex.h
+++ b/third_party/re2/util/mutex.h
@@ -76,7 +76,7 @@ class Mutex {
MutexType mutex_;
// Catch the error of writing Mutex when intending MutexLock.
- Mutex(Mutex *ignored) {}
+ Mutex(Mutex *ignored);
// Disallow "evil" constructors
Mutex(const Mutex&);
void operator=(const Mutex&);
@@ -189,6 +189,27 @@ class WriterMutexLock {
#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
+// Provide safe way to declare and use global, linker-initialized mutex. Sigh.
+#ifdef HAVE_PTHREAD
+
+#define GLOBAL_MUTEX(name) \
+ static pthread_mutex_t (name) = PTHREAD_MUTEX_INITIALIZER
+#define GLOBAL_MUTEX_LOCK(name) \
+ pthread_mutex_lock(&(name))
+#define GLOBAL_MUTEX_UNLOCK(name) \
+ pthread_mutex_unlock(&(name))
+
+#else
+
+#define GLOBAL_MUTEX(name) \
+ static Mutex name
+#define GLOBAL_MUTEX_LOCK(name) \
+ name.Lock()
+#define GLOBAL_MUTEX_UNLOCK(name) \
+ name.Unlock()
+
+#endif
+
} // namespace re2
#endif /* #define RE2_UTIL_MUTEX_H_ */
« no previous file with comments | « third_party/re2/util/logging.h ('k') | third_party/re2/util/sparse_array.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698