mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-17 19:09:02 +00:00
Macros for manual critical sections
This commit is contained in:
parent
d52397b3c0
commit
43163a5a4d
@ -277,7 +277,7 @@ public:
|
||||
|
||||
void BeginMessage(const char* pszCommand)
|
||||
{
|
||||
cs_vSend.Enter("cs_vSend", __FILE__, __LINE__);
|
||||
ENTER_CRITICAL_SECTION(cs_vSend);
|
||||
if (nHeaderStart != -1)
|
||||
AbortMessage();
|
||||
nHeaderStart = vSend.size();
|
||||
@ -296,7 +296,7 @@ public:
|
||||
vSend.resize(nHeaderStart);
|
||||
nHeaderStart = -1;
|
||||
nMessageStart = -1;
|
||||
cs_vSend.Leave();
|
||||
LEAVE_CRITICAL_SECTION(cs_vSend);
|
||||
|
||||
if (fDebug)
|
||||
printf("(aborted)\n");
|
||||
@ -334,7 +334,7 @@ public:
|
||||
|
||||
nHeaderStart = -1;
|
||||
nMessageStart = -1;
|
||||
cs_vSend.Leave();
|
||||
LEAVE_CRITICAL_SECTION(cs_vSend);
|
||||
}
|
||||
|
||||
void EndMessageAbortIfEmpty()
|
||||
|
||||
@ -254,6 +254,12 @@ public:
|
||||
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 ENTER_CRITICAL_SECTION(cs) \
|
||||
(cs).Enter(#cs, __FILE__, __LINE__)
|
||||
|
||||
#define LEAVE_CRITICAL_SECTION(cs) \
|
||||
(cs).Leave()
|
||||
|
||||
class CTryCriticalBlock
|
||||
{
|
||||
protected:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user