mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Use LOCK macros for non-recursive locks
Instead of std::unique_lock.
This commit is contained in:
@@ -49,7 +49,7 @@ struct CUpdatedBlock
|
||||
int height;
|
||||
};
|
||||
|
||||
static std::mutex cs_blockchange;
|
||||
static CWaitableCriticalSection cs_blockchange;
|
||||
static std::condition_variable cond_blockchange;
|
||||
static CUpdatedBlock latestblock;
|
||||
|
||||
@@ -224,7 +224,7 @@ static UniValue waitfornewblock(const JSONRPCRequest& request)
|
||||
|
||||
CUpdatedBlock block;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cs_blockchange);
|
||||
WAIT_LOCK(cs_blockchange, lock);
|
||||
block = latestblock;
|
||||
if(timeout)
|
||||
cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&block]{return latestblock.height != block.height || latestblock.hash != block.hash || !IsRPCRunning(); });
|
||||
@@ -266,7 +266,7 @@ static UniValue waitforblock(const JSONRPCRequest& request)
|
||||
|
||||
CUpdatedBlock block;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cs_blockchange);
|
||||
WAIT_LOCK(cs_blockchange, lock);
|
||||
if(timeout)
|
||||
cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&hash]{return latestblock.hash == hash || !IsRPCRunning();});
|
||||
else
|
||||
@@ -309,7 +309,7 @@ static UniValue waitforblockheight(const JSONRPCRequest& request)
|
||||
|
||||
CUpdatedBlock block;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cs_blockchange);
|
||||
WAIT_LOCK(cs_blockchange, lock);
|
||||
if(timeout)
|
||||
cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&height]{return latestblock.height >= height || !IsRPCRunning();});
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user