mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 13:59:06 +01:00
Macros for manual critical sections
This commit is contained in:
parent
b25474d1be
commit
88bc5f9485
@ -279,7 +279,7 @@ public:
|
|||||||
|
|
||||||
void BeginMessage(const char* pszCommand)
|
void BeginMessage(const char* pszCommand)
|
||||||
{
|
{
|
||||||
cs_vSend.Enter("cs_vSend", __FILE__, __LINE__);
|
ENTER_CRITICAL_SECTION(cs_vSend);
|
||||||
if (nHeaderStart != -1)
|
if (nHeaderStart != -1)
|
||||||
AbortMessage();
|
AbortMessage();
|
||||||
nHeaderStart = vSend.size();
|
nHeaderStart = vSend.size();
|
||||||
@ -298,7 +298,7 @@ public:
|
|||||||
vSend.resize(nHeaderStart);
|
vSend.resize(nHeaderStart);
|
||||||
nHeaderStart = -1;
|
nHeaderStart = -1;
|
||||||
nMessageStart = -1;
|
nMessageStart = -1;
|
||||||
cs_vSend.Leave();
|
LEAVE_CRITICAL_SECTION(cs_vSend);
|
||||||
|
|
||||||
if (fDebug)
|
if (fDebug)
|
||||||
printf("(aborted)\n");
|
printf("(aborted)\n");
|
||||||
@ -336,7 +336,7 @@ public:
|
|||||||
|
|
||||||
nHeaderStart = -1;
|
nHeaderStart = -1;
|
||||||
nMessageStart = -1;
|
nMessageStart = -1;
|
||||||
cs_vSend.Leave();
|
LEAVE_CRITICAL_SECTION(cs_vSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndMessageAbortIfEmpty()
|
void EndMessageAbortIfEmpty()
|
||||||
|
@ -218,6 +218,12 @@ public:
|
|||||||
#define CRITICAL_BLOCK(cs) \
|
#define CRITICAL_BLOCK(cs) \
|
||||||
if (CCriticalBlock criticalblock = CCriticalBlock(cs, #cs, __FILE__, __LINE__))
|
if (CCriticalBlock criticalblock = CCriticalBlock(cs, #cs, __FILE__, __LINE__))
|
||||||
|
|
||||||
|
#define ENTER_CRITICAL_SECTION(cs) \
|
||||||
|
(cs).Enter(#cs, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
#define LEAVE_CRITICAL_SECTION(cs) \
|
||||||
|
(cs).Leave()
|
||||||
|
|
||||||
class CTryCriticalBlock
|
class CTryCriticalBlock
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user