Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / base / criticalsection.h
index a950a47..a2d9bca 100644 (file)
@@ -12,6 +12,7 @@
 #define WEBRTC_BASE_CRITICALSECTION_H__
 
 #include "webrtc/base/constructormagic.h"
+#include "webrtc/base/thread_annotations.h"
 
 #if defined(WEBRTC_WIN)
 #include "webrtc/base/win32.h"
@@ -34,7 +35,7 @@
 namespace rtc {
 
 #if defined(WEBRTC_WIN)
-class CriticalSection {
+class LOCKABLE CriticalSection {
  public:
   CriticalSection() {
     InitializeCriticalSection(&crit_);
@@ -44,18 +45,18 @@ class CriticalSection {
   ~CriticalSection() {
     DeleteCriticalSection(&crit_);
   }
-  void Enter() {
+  void Enter() EXCLUSIVE_LOCK_FUNCTION() {
     EnterCriticalSection(&crit_);
     TRACK_OWNER(thread_ = GetCurrentThreadId());
   }
-  bool TryEnter() {
+  bool TryEnter() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
     if (TryEnterCriticalSection(&crit_) != FALSE) {
       TRACK_OWNER(thread_ = GetCurrentThreadId());
       return true;
     }
     return false;
   }
-  void Leave() {
+  void Leave() UNLOCK_FUNCTION() {
     TRACK_OWNER(thread_ = 0);
     LeaveCriticalSection(&crit_);
   }
@@ -71,7 +72,7 @@ class CriticalSection {
 #endif // WEBRTC_WIN 
 
 #if defined(WEBRTC_POSIX)
-class CriticalSection {
+class LOCKABLE CriticalSection {
  public:
   CriticalSection() {
     pthread_mutexattr_t mutex_attribute;
@@ -84,18 +85,18 @@ class CriticalSection {
   ~CriticalSection() {
     pthread_mutex_destroy(&mutex_);
   }
-  void Enter() {
+  void Enter() EXCLUSIVE_LOCK_FUNCTION() {
     pthread_mutex_lock(&mutex_);
     TRACK_OWNER(thread_ = pthread_self());
   }
-  bool TryEnter() {
+  bool TryEnter() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
     if (pthread_mutex_trylock(&mutex_) == 0) {
       TRACK_OWNER(thread_ = pthread_self());
       return true;
     }
     return false;
   }
-  void Leave() {
+  void Leave() UNLOCK_FUNCTION() {
     TRACK_OWNER(thread_ = 0);
     pthread_mutex_unlock(&mutex_);
   }
@@ -111,13 +112,13 @@ class CriticalSection {
 #endif // WEBRTC_POSIX
 
 // CritScope, for serializing execution through a scope.
-class CritScope {
+class SCOPED_LOCKABLE CritScope {
  public:
-  explicit CritScope(CriticalSection *pcrit) {
+  explicit CritScope(CriticalSection *pcrit) EXCLUSIVE_LOCK_FUNCTION(pcrit) {
     pcrit_ = pcrit;
     pcrit_->Enter();
   }
-  ~CritScope() {
+  ~CritScope() UNLOCK_FUNCTION() {
     pcrit_->Leave();
   }
  private: