mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
partial #15842: Add WITH_LOCK macro: run code while locking a mutex
This commit is contained in:
parent
a8aee57447
commit
a612ec5087
10
src/sync.h
10
src/sync.h
@ -205,6 +205,16 @@ using DebugLock = UniqueLock<typename std::remove_reference<typename std::remove
|
||||
LeaveCritical(); \
|
||||
}
|
||||
|
||||
//! Run code while locking a mutex.
|
||||
//!
|
||||
//! Examples:
|
||||
//!
|
||||
//! WITH_LOCK(cs, shared_val = shared_val + 1);
|
||||
//!
|
||||
//! int val = WITH_LOCK(cs, return shared_val);
|
||||
//!
|
||||
#define WITH_LOCK(cs, code) [&] { LOCK(cs); code; }()
|
||||
|
||||
class CSemaphore
|
||||
{
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user