diff options
author | Andrew Stitcher <astitcher@apache.org> | 2010-09-08 16:49:19 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2010-09-08 16:49:19 +0000 |
commit | 82b6ba81103baac0f56b402645352c0c9f948680 (patch) | |
tree | 4e7ea14fdbe671f7fc99dbb0385e87a8995034aa /cpp/src | |
parent | 7a843fa13909d54281639bd1b7d2348b853287be (diff) | |
download | qpid-python-82b6ba81103baac0f56b402645352c0c9f948680.tar.gz |
Coalesce checking for the drained and stopped conditions into a single
function
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@995136 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/sys/rdma/RdmaIO.cpp | 38 | ||||
-rw-r--r-- | cpp/src/qpid/sys/rdma/RdmaIO.h | 1 |
2 files changed, 22 insertions, 17 deletions
diff --git a/cpp/src/qpid/sys/rdma/RdmaIO.cpp b/cpp/src/qpid/sys/rdma/RdmaIO.cpp index 6591c6e676..f0ae7e5d77 100644 --- a/cpp/src/qpid/sys/rdma/RdmaIO.cpp +++ b/cpp/src/qpid/sys/rdma/RdmaIO.cpp @@ -254,9 +254,8 @@ namespace Rdma { return; case EXIT: // If we just processed completions we might need to delete ourselves - if (notifyCallback && outstandingWrites == 0) { - doStoppedCallback(); - } + // TODO: XXX: can we delete ourselves correctly in notifyPendingWrite()? + checkDrainedStopped(); return; } } while (true); @@ -321,20 +320,8 @@ namespace Rdma { } while (!state.boolCompareAndSwap(oldState, newState)); } - // If we've got all the write confirmations and we're draining - // We might get deleted in the drained callback so return immediately - if (draining) { - if (outstandingWrites == 0) { - draining = false; - doDrainedCallback(); - } - return; - } - - // We might need to delete ourselves - if (notifyCallback && outstandingWrites == 0) { - doStoppedCallback(); - } + // We might delete ourselves in here so return immediately + checkDrainedStopped(); } void AsynchIO::processCompletions() { @@ -448,6 +435,23 @@ namespace Rdma { } } + void AsynchIO::checkDrainedStopped() { + // If we've got all the write confirmations and we're draining + // We might get deleted in the drained callback so return immediately + if (draining) { + if (outstandingWrites == 0) { + draining = false; + doDrainedCallback(); + } + return; + } + + // We might need to delete ourselves + if (notifyCallback && outstandingWrites == 0) { + doStoppedCallback(); + } + } + void AsynchIO::doDrainedCallback() { NotifyCallback nc; nc.swap(notifyCallback); diff --git a/cpp/src/qpid/sys/rdma/RdmaIO.h b/cpp/src/qpid/sys/rdma/RdmaIO.h index 5876646b96..8d5dbc5f3e 100644 --- a/cpp/src/qpid/sys/rdma/RdmaIO.h +++ b/cpp/src/qpid/sys/rdma/RdmaIO.h @@ -101,6 +101,7 @@ namespace Rdma { void dataEvent(); void processCompletions(); void doWriteCallback(); + void checkDrainedStopped(); void doStoppedCallback(); void doDrainedCallback(); }; |