mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 19:34:39 +01:00
Code cleanup. Use lambdas in Thread.h (port from Dolphin).
This commit is contained in:
1 parent
df3765a320
commit
2fb7a77135
2 files changed
+5
-35
No files matched your search
+3
-1
@@ -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);
|
||||
|
||||
+2
-34
@@ -73,7 +73,7 @@ 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user