summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Cristiano <jordan.cristi@gmail.com>2013-11-10 04:57:11 -0500
committerJordan Cristiano <jordan.cristi@gmail.com>2013-11-10 04:57:11 -0500
commit3a28afd8d5d55dc4a90199029d50a7e13dc7c7b2 (patch)
tree1d865111c31050f720abcd29a6c1c559d12dd013 /Source/Core
parente013a74cdbdf9cebb150bc59c196a5ff3f6af710 (diff)
Changed thread barrier and event to use a lamba wait predicate instead of a functor.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/Thread.h42
1 files changed, 6 insertions, 36 deletions
diff --git a/Source/Core/Common/Src/Thread.h b/Source/Core/Common/Src/Thread.h
index bfd7ea0308..b2e9572ce5 100644
--- a/Source/Core/Common/Src/Thread.h
+++ b/Source/Core/Common/Src/Thread.h
@@ -38,7 +38,7 @@ class Event
public:
Event()
: is_set(false)
- {};
+ {}
void Set()
{
@@ -53,34 +53,20 @@ public:
void Wait()
{
std::unique_lock<std::mutex> lk(m_mutex);
- m_condvar.wait(lk, IsSet(this));
+ m_condvar.wait(lk, [&]{ return is_set; });
is_set = false;
}
void Reset()
{
std::unique_lock<std::mutex> lk(m_mutex);
- // no other action required, since wait loops on the predicate and any lingering signal will get cleared on the first iteration
+ // no other action required, since wait loops on
+ // the predicate and any lingering signal will get
+ // cleared on the first iteration
is_set = false;
}
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;
@@ -110,28 +96,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;