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

Unified Diff: Source/wtf/ThreadingPrimitives.h

Issue 415083002: [oilpan]: fix deadlock when leaving a safepoint and sweeping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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: Source/wtf/ThreadingPrimitives.h
diff --git a/Source/wtf/ThreadingPrimitives.h b/Source/wtf/ThreadingPrimitives.h
index aa98884bd1a12731c2e84adce6c9e8d69fbd3888..4527d1e7a5259d3b021042fae67b11d648e8a4fc 100644
--- a/Source/wtf/ThreadingPrimitives.h
+++ b/Source/wtf/ThreadingPrimitives.h
@@ -48,7 +48,12 @@
namespace WTF {
#if USE(PTHREADS)
-typedef pthread_mutex_t PlatformMutex;
+struct PlatformMutex {
+ pthread_mutex_t m_internalMutex;
+#ifndef NDEBUG
+ size_t m_recursionCount;
+#endif
+};
typedef pthread_cond_t PlatformCondition;
#elif OS(WIN)
struct PlatformMutex {
@@ -71,23 +76,39 @@ typedef void* PlatformMutex;
typedef void* PlatformCondition;
#endif
-class WTF_EXPORT Mutex {
- WTF_MAKE_NONCOPYABLE(Mutex); WTF_MAKE_FAST_ALLOCATED;
+class WTF_EXPORT MutexBase {
+ WTF_MAKE_NONCOPYABLE(MutexBase); WTF_MAKE_FAST_ALLOCATED;
public:
- Mutex();
- ~Mutex();
+ ~MutexBase();
void lock();
- bool tryLock();
void unlock();
+#ifndef NDEBUG
tkent 2014/07/25 05:11:44 #if ENABLE(ASSERT) We have a bot with Release + a
wibling-chromium 2014/07/25 09:31:28 Done.
+ bool locked() { return m_mutex.m_recursionCount > 0; }
+#endif
public:
PlatformMutex& impl() { return m_mutex; }
-private:
+
+protected:
+ MutexBase(bool recursive);
+
PlatformMutex m_mutex;
};
-typedef Locker<Mutex> MutexLocker;
+class WTF_EXPORT Mutex : public MutexBase {
+public:
+ Mutex() : MutexBase(false) { }
+ bool tryLock();
+};
+
+class WTF_EXPORT RecursiveMutex : public MutexBase {
+public:
+ RecursiveMutex() : MutexBase(true) { }
+ bool tryLock();
+};
+
+typedef Locker<MutexBase> MutexLocker;
class MutexTryLocker {
WTF_MAKE_NONCOPYABLE(MutexTryLocker);
@@ -112,10 +133,10 @@ public:
ThreadCondition();
~ThreadCondition();
- void wait(Mutex&);
+ void wait(MutexBase&);
// Returns true if the condition was signaled before absoluteTime, false if the absoluteTime was reached or is in the past.
// The absoluteTime is in seconds, starting on January 1, 1970. The time is assumed to use the same time zone as WTF::currentTime().
- bool timedWait(Mutex&, double absoluteTime);
+ bool timedWait(MutexBase&, double absoluteTime);
void signal();
void broadcast();
@@ -132,6 +153,7 @@ DWORD absoluteTimeToWaitTimeoutInterval(double absoluteTime);
} // namespace WTF
using WTF::Mutex;
tkent 2014/07/25 05:11:44 Add |using WTF::MutexBase| too.
wibling-chromium 2014/07/25 09:31:28 Done.
+using WTF::RecursiveMutex;
using WTF::MutexLocker;
using WTF::MutexTryLocker;
using WTF::ThreadCondition;

Powered by Google App Engine
This is Rietveld 408576698