mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-11 12:03:04 +02:00
Use LOCK macros for non-recursive locks
Instead of std::unique_lock.
This commit is contained in:
@@ -69,7 +69,7 @@ class WorkQueue
|
||||
{
|
||||
private:
|
||||
/** Mutex protects entire object */
|
||||
std::mutex cs;
|
||||
CWaitableCriticalSection cs;
|
||||
std::condition_variable cond;
|
||||
std::deque<std::unique_ptr<WorkItem>> queue;
|
||||
bool running;
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
/** Enqueue a work item */
|
||||
bool Enqueue(WorkItem* item)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cs);
|
||||
LOCK(cs);
|
||||
if (queue.size() >= maxDepth) {
|
||||
return false;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
while (true) {
|
||||
std::unique_ptr<WorkItem> i;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cs);
|
||||
WAIT_LOCK(cs, lock);
|
||||
while (running && queue.empty())
|
||||
cond.wait(lock);
|
||||
if (!running)
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
/** Interrupt and exit loops */
|
||||
void Interrupt()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cs);
|
||||
LOCK(cs);
|
||||
running = false;
|
||||
cond.notify_all();
|
||||
}
|
||||
|
Reference in New Issue
Block a user