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

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: review feedback 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
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | Source/wtf/ThreadingPthreads.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/ThreadingPrimitives.h
diff --git a/Source/wtf/ThreadingPrimitives.h b/Source/wtf/ThreadingPrimitives.h
index aa98884bd1a12731c2e84adce6c9e8d69fbd3888..cc37184da172a27889806d75775bd656331b8c21 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;
+#if ENABLE(ASSERT)
+ 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();
+#if ENABLE(ASSERT)
+ 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();
@@ -131,7 +152,9 @@ DWORD absoluteTimeToWaitTimeoutInterval(double absoluteTime);
} // namespace WTF
+using WTF::MutexBase;
using WTF::Mutex;
+using WTF::RecursiveMutex;
using WTF::MutexLocker;
using WTF::MutexTryLocker;
using WTF::ThreadCondition;
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | Source/wtf/ThreadingPthreads.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698