diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-06 18:39:12 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-09 01:59:46 +0200 |
commit | f8dcd5ca6f55ad49807cf7491c1f153f6158400e (patch) | |
tree | 6049e300099aa5f509e408acfff0236367b4a26e /src/util.h | |
parent | 138d08c5315c45b3dd08184c4eeb77ee3e47ef0a (diff) |
Use scoped locks instead of CRITICAL_BLOCK
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/util.h b/src/util.h index 635790b71b..7027e62b09 100644 --- a/src/util.h +++ b/src/util.h @@ -282,13 +282,10 @@ typedef boost::interprocess::interprocess_condition CConditionVariable; #define NOTIFY_ALL(name) \ do { (name).notify_all(); } while(0) -#define CRITICAL_BLOCK(cs) \ - for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \ - for (CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce; fcriticalblockonce=false) - -#define WAITABLE_CRITICAL_BLOCK(cs) \ - for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by WAITABLE_CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \ - for (CWaitableCriticalBlock waitablecriticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce; fcriticalblockonce=false) +#define LOCK(cs) CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__) +#define LOCK2(cs1,cs2) CCriticalBlock criticalblock1(cs1, #cs1, __FILE__, __LINE__),criticalblock2(cs2, #cs2, __FILE__, __LINE__) +#define TRY_LOCK(cs,name) CCriticalBlock name(cs, #cs, __FILE__, __LINE__, true) +#define WAITABLE_LOCK(cs) CWaitableCriticalBlock waitablecriticalblock(cs, #cs, __FILE__, __LINE__) #define ENTER_CRITICAL_SECTION(cs) \ { \ @@ -302,10 +299,6 @@ typedef boost::interprocess::interprocess_condition CConditionVariable; LeaveCritical(); \ } -#define TRY_CRITICAL_BLOCK(cs) \ - for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by TRY_CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \ - for (CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__, true); fcriticalblockonce && (fcriticalblockonce = criticalblock); fcriticalblockonce=false) - // This is exactly like std::string, but with a custom allocator. // (secure_allocator<> is defined in serialize.h) |