diff options
author | A. Unique TensorFlower <nobody@tensorflow.org> | 2016-05-23 14:59:26 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-05-23 16:03:09 -0700 |
commit | 81af087fb71a8323b0af09694a4de1ab54646de8 (patch) | |
tree | 0f06c3289f848c387ed331646ff81620c7d08750 /tensorflow/stream_executor/platform | |
parent | 5ab5d97710e27022b789939b26f63386abdfb526 (diff) |
Add macros for mutex_lock and shared_lock, so compilation fails if
mutex_lock is used incorrectly with mutex_lock(mu)
Change: 123048062
Diffstat (limited to 'tensorflow/stream_executor/platform')
-rw-r--r-- | tensorflow/stream_executor/platform/default/mutex.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tensorflow/stream_executor/platform/default/mutex.h b/tensorflow/stream_executor/platform/default/mutex.h index 0ce1eeadbb..b834895da5 100644 --- a/tensorflow/stream_executor/platform/default/mutex.h +++ b/tensorflow/stream_executor/platform/default/mutex.h @@ -35,6 +35,9 @@ limitations under the License. namespace perftools { namespace gputools { +#undef mutex_lock +#undef shared_lock + enum ConditionResult { kCond_Timeout, kCond_MaybeNotified }; #ifdef STREAM_EXECUTOR_USE_SHARED_MUTEX @@ -62,6 +65,9 @@ class SCOPED_LOCKABLE mutex_lock : public std::unique_lock<BaseMutex> { ~mutex_lock() RELEASE() {} }; +// Catch bug where variable name is omitted, e.g. mutex_lock (mu); +#define mutex_lock(x) static_assert(0, "mutex_lock_decl_missing_var_name"); + #ifdef STREAM_EXECUTOR_USE_SHARED_MUTEX // TODO(vrv): Annotate these with ACQUIRE_SHARED after implementing // as classes. @@ -70,6 +76,9 @@ typedef std::shared_lock<BaseMutex> shared_lock; typedef mutex_lock shared_lock; #endif +// Catch bug where variable name is omitted, e.g. shared_lock (mu); +#define shared_lock(x) static_assert(0, "shared_lock_decl_missing_var_name"); + using std::condition_variable; inline ConditionResult WaitForMilliseconds(mutex_lock* mu, |