From 2fb7a771354a41a550502bb2be007f025bb846a5 Mon Sep 17 00:00:00 2001 From: Sacha Date: Tue, 12 Nov 2013 22:34:40 +1000 Subject: [PATCH] Code cleanup. Use lambdas in Thread.h (port from Dolphin). --- Common/Thread.cpp | 4 +++- Common/Thread.h | 36 ++---------------------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/Common/Thread.cpp b/Common/Thread.cpp index 2ca3ec08f8..c6d94258ba 100644 --- a/Common/Thread.cpp +++ b/Common/Thread.cpp @@ -187,7 +187,9 @@ static void ThreadnameKeyAlloc() void SetCurrentThreadName(const char* szThreadName) { -#ifdef BLACKBERRY +#ifdef APPLE + pthread_setname_np(szThreadName); +#elif defined(BLACKBERRY) pthread_setname_np(pthread_self(), szThreadName); #else pthread_once(&threadname_key_once, ThreadnameKeyAlloc); diff --git a/Common/Thread.h b/Common/Thread.h index 0726bef34c..677ae51a61 100644 --- a/Common/Thread.h +++ b/Common/Thread.h @@ -73,7 +73,7 @@ public: void Wait() { std::unique_lock lk(m_mutex); - m_condvar.wait(lk, IsSet(this)); + m_condvar.wait(lk, [&]{ return is_set; }); is_set = false; } @@ -85,22 +85,6 @@ public: } private: - class IsSet - { - public: - IsSet(const Event* ev) - : m_event(ev) - {} - - bool operator()() - { - return m_event->is_set; - } - - private: - const Event* const m_event; - }; - volatile bool is_set; std::condition_variable m_condvar; std::mutex m_mutex; @@ -130,28 +114,12 @@ public: } else { - m_condvar.wait(lk, IsDoneWating(this)); + m_condvar.wait(lk, [&]{ return (0 == m_waiting); }); return false; } } private: - class IsDoneWating - { - public: - IsDoneWating(const Barrier* bar) - : m_bar(bar) - {} - - bool operator()() - { - return (0 == m_bar->m_waiting); - } - - private: - const Barrier* const m_bar; - }; - std::condition_variable m_condvar; std::mutex m_mutex; const size_t m_count;