summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-06 16:52:06 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-06 16:52:06 +0000
commitff9cfce7ec2ae06df4ac413cfde3bfd7ae503677 (patch)
treee7e70f4c29d90c16d687c42f9b0c8cbeec8400d0 /third_party
parentb45539429af531249cecab20c128ef12d8e131a8 (diff)
downloadchromium_src-ff9cfce7ec2ae06df4ac413cfde3bfd7ae503677.zip
chromium_src-ff9cfce7ec2ae06df4ac413cfde3bfd7ae503677.tar.gz
chromium_src-ff9cfce7ec2ae06df4ac413cfde3bfd7ae503677.tar.bz2
Add some fixes to the Linux version of criticalsection.h
Review URL: http://codereview.chromium.org/243095 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28122 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/libjingle/files/talk/base/criticalsection.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/third_party/libjingle/files/talk/base/criticalsection.h b/third_party/libjingle/files/talk/base/criticalsection.h
index fbe7382..937c5bb 100644
--- a/third_party/libjingle/files/talk/base/criticalsection.h
+++ b/third_party/libjingle/files/talk/base/criticalsection.h
@@ -80,23 +80,36 @@ private:
#ifdef POSIX
class CriticalSection {
-public:
+ public:
CriticalSection() {
pthread_mutexattr_t mutex_attribute;
+ pthread_mutexattr_init(&mutex_attribute);
pthread_mutexattr_settype(&mutex_attribute, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&mutex_, &mutex_attribute);
+ pthread_mutexattr_destroy(&mutex_attribute);
+ TRACK_OWNER(thread_ = 0);
}
~CriticalSection() {
pthread_mutex_destroy(&mutex_);
}
void Enter() {
pthread_mutex_lock(&mutex_);
+ TRACK_OWNER(thread_ = pthread_self());
}
void Leave() {
+ TRACK_OWNER(thread_ = 0);
pthread_mutex_unlock(&mutex_);
}
-private:
+
+#if CS_TRACK_OWNER
+ bool CurrentThreadIsOwner() const {
+ return pthread_equal(thread_, pthread_self());
+ }
+#endif // CS_TRACK_OWNER
+
+ private:
pthread_mutex_t mutex_;
+ TRACK_OWNER(pthread_t thread_);
};
#endif // POSIX