summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-04-11 08:13:48 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-04-11 08:13:48 +0100
commit8ac864359e202b3247a0a45ebbf0d87316b90d1a (patch)
tree2758b381a6aba20d0a88172249e304b4642933e3
parent99213561ac6238cc47842583bf4ea4e1357a41fa (diff)
-rw-r--r--common/os_thread.hpp28
-rw-r--r--common/os_thread_test.cpp18
2 files changed, 12 insertions, 34 deletions
diff --git a/common/os_thread.hpp b/common/os_thread.hpp
index 6edf148c..6573d0f2 100644
--- a/common/os_thread.hpp
+++ b/common/os_thread.hpp
@@ -322,8 +322,9 @@ namespace os {
inline void
wait(unique_lock<mutex> & lock, std::function<bool()> pred) {
- while (!pred)
+ while (!pred) {
wait(lock);
+ }
}
};
@@ -443,31 +444,6 @@ namespace os {
#endif
}
-#if 0
- template< typename Function, typename... Args >
- class thread_data
- {
- public:
- thread_data(Function &&f, Args&&... args) :
- _f(std::forward<Function>(f)),
- _args(std::forward<Args...>(args...))
- {}
-
- thread_data(const thread_data&) = delete;
- thread_data& operator=(const thread_data&) = delete;
-
- void operator() (void) {
- //auto f = std::bind(std::forward<Function>(_f), std::forward<Args>(_args)...);
- //f();
- _f(std::tie(_args));
- }
-
- private:
- typename std::decay<Function>::type _f;
- std::tuple<typename std::decay<Args>::type...> _args;
- };
-#endif
-
template< class Function, class... Args >
explicit thread(Function &&f, Args&&... args) {
auto bound = std::bind(std::forward<Function>(f), std::forward<Args>(args)...);
diff --git a/common/os_thread_test.cpp b/common/os_thread_test.cpp
index ff966f36..aeec6a93 100644
--- a/common/os_thread_test.cpp
+++ b/common/os_thread_test.cpp
@@ -77,14 +77,16 @@ struct Data
volatile unsigned c = 0;
};
-
-static os::mutex cerr_mutex;
-
-#define WITH_CERR_MUTEX(_stmts) \
- { \
- os::unique_lock<os::mutex> cerr_lock(cerr_mutex); \
- _stmts \
- }
+#if 0
+ static os::mutex cerr_mutex;
+# define WITH_CERR_MUTEX(_stmts) \
+ { \
+ os::unique_lock<os::mutex> cerr_lock(cerr_mutex); \
+ _stmts \
+ }
+#else
+# define WITH_CERR_MUTEX(_stmts)
+#endif
static void cvf(Data *data, unsigned idx)