From f41959ccb2d9d4c722fe8fc3351401d53bcf4900 Mon Sep 17 00:00:00 2001 From: Manjunath Kudlur Date: Fri, 6 Nov 2015 16:27:58 -0800 Subject: TensorFlow: Initial commit of TensorFlow library. TensorFlow is an open source software library for numerical computation using data flow graphs. Base CL: 107276108 --- tensorflow/core/platform/default/mutex.h | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tensorflow/core/platform/default/mutex.h (limited to 'tensorflow/core/platform/default/mutex.h') diff --git a/tensorflow/core/platform/default/mutex.h b/tensorflow/core/platform/default/mutex.h new file mode 100644 index 0000000000..b26b418e1b --- /dev/null +++ b/tensorflow/core/platform/default/mutex.h @@ -0,0 +1,33 @@ +#ifndef TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_ +#define TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_ + +#include +#include +#include + +namespace tensorflow { + +enum LinkerInitialized { LINKER_INITIALIZED }; + +// A class that wraps around the std::mutex implementation, only adding an +// additional LinkerInitialized constructor interface. +class mutex : public std::mutex { + public: + mutex() {} + // The default implementation of std::mutex is safe to use after the linker + // initializations + explicit mutex(LinkerInitialized x) {} +}; + +using std::condition_variable; +typedef std::unique_lock mutex_lock; + +inline ConditionResult WaitForMilliseconds(mutex_lock* mu, + condition_variable* cv, int64 ms) { + std::cv_status s = cv->wait_for(*mu, std::chrono::milliseconds(ms)); + return (s == std::cv_status::timeout) ? kCond_Timeout : kCond_MaybeNotified; +} + +} // namespace tensorflow + +#endif // TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_ -- cgit v1.2.3