aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/stream_executor/platform
diff options
context:
space:
mode:
authorGravatar Vijay Vasudevan <vrv@google.com>2016-02-17 11:42:30 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-02-17 12:56:41 -0800
commitfe056f0b5e52db86766761f5e6446a89c1aa3938 (patch)
tree68bce0e257d181a3fa37f83c97fdff0fdad877fc /tensorflow/stream_executor/platform
parent19d632338f983e02dd0268b931e9cced03b74805 (diff)
Merge changes from github.
Change: 114882676
Diffstat (limited to 'tensorflow/stream_executor/platform')
-rw-r--r--tensorflow/stream_executor/platform/default/mutex.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/tensorflow/stream_executor/platform/default/mutex.h b/tensorflow/stream_executor/platform/default/mutex.h
index 3b203c285c..0ce1eeadbb 100644
--- a/tensorflow/stream_executor/platform/default/mutex.h
+++ b/tensorflow/stream_executor/platform/default/mutex.h
@@ -45,20 +45,29 @@ typedef std::mutex BaseMutex;
// A class that wraps around the std::mutex implementation, only adding an
// additional LinkerInitialized constructor interface.
-class mutex : public BaseMutex {
+class LOCKABLE mutex : public BaseMutex {
public:
mutex() {}
// The default implementation of std::mutex is safe to use after the linker
// initializations
explicit mutex(LinkerInitialized x) {}
+
+ void lock() ACQUIRE() { BaseMutex::lock(); }
+ void unlock() RELEASE() { BaseMutex::unlock(); }
};
-typedef std::unique_lock<BaseMutex> mutex_lock;
+class SCOPED_LOCKABLE mutex_lock : public std::unique_lock<BaseMutex> {
+ public:
+ mutex_lock(class mutex& m) ACQUIRE(m) : std::unique_lock<BaseMutex>(m) {}
+ ~mutex_lock() RELEASE() {}
+};
#ifdef STREAM_EXECUTOR_USE_SHARED_MUTEX
+// TODO(vrv): Annotate these with ACQUIRE_SHARED after implementing
+// as classes.
typedef std::shared_lock<BaseMutex> shared_lock;
#else
-typedef std::unique_lock<BaseMutex> shared_lock;
+typedef mutex_lock shared_lock;
#endif
using std::condition_variable;