mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Use LOCK macros for non-recursive locks
Instead of std::unique_lock.
This commit is contained in:
parent
1382913e61
commit
9c4dc597dd
11 changed files with 26 additions and 24 deletions
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <threadinterrupt.h>
|
||||
|
||||
#include <sync.h>
|
||||
|
||||
CThreadInterrupt::CThreadInterrupt() : flag(false) {}
|
||||
|
||||
CThreadInterrupt::operator bool() const
|
||||
|
|
@ -20,7 +22,7 @@ void CThreadInterrupt::reset()
|
|||
void CThreadInterrupt::operator()()
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mut);
|
||||
LOCK(mut);
|
||||
flag.store(true, std::memory_order_release);
|
||||
}
|
||||
cond.notify_all();
|
||||
|
|
@ -28,7 +30,7 @@ void CThreadInterrupt::operator()()
|
|||
|
||||
bool CThreadInterrupt::sleep_for(std::chrono::milliseconds rel_time)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mut);
|
||||
WAIT_LOCK(mut, lock);
|
||||
return !cond.wait_for(lock, rel_time, [this]() { return flag.load(std::memory_order_acquire); });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue