aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-02-11 20:02:55 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-02-11 21:59:33 +0100
commit88bc5f94852a0b2839a3ef4e1a6a5168d02f6b55 (patch)
treeaf95db0a5e8bfc151165a0958956710e5b3c8e5d
parentb25474d1bea42ab6e20fb2b86714db0ece8f1c74 (diff)
Macros for manual critical sections
-rw-r--r--src/net.h6
-rw-r--r--src/util.h6
2 files changed, 9 insertions, 3 deletions
diff --git a/src/net.h b/src/net.h
index 2be9541cd1..a66bc15438 100644
--- a/src/net.h
+++ b/src/net.h
@@ -279,7 +279,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();
@@ -298,7 +298,7 @@ public:
vSend.resize(nHeaderStart);
nHeaderStart = -1;
nMessageStart = -1;
- cs_vSend.Leave();
+ LEAVE_CRITICAL_SECTION(cs_vSend);
if (fDebug)
printf("(aborted)\n");
@@ -336,7 +336,7 @@ public:
nHeaderStart = -1;
nMessageStart = -1;
- cs_vSend.Leave();
+ LEAVE_CRITICAL_SECTION(cs_vSend);
}
void EndMessageAbortIfEmpty()
diff --git a/src/util.h b/src/util.h
index 8dcedb147b..ddc8791b38 100644
--- a/src/util.h
+++ b/src/util.h
@@ -218,6 +218,12 @@ public:
#define CRITICAL_BLOCK(cs) \
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
{
protected: