summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client/StateManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/client/StateManager.cpp')
-rw-r--r--cpp/src/qpid/client/StateManager.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/cpp/src/qpid/client/StateManager.cpp b/cpp/src/qpid/client/StateManager.cpp
index 9239950a3f..5462e0fed4 100644
--- a/cpp/src/qpid/client/StateManager.cpp
+++ b/cpp/src/qpid/client/StateManager.cpp
@@ -60,6 +60,18 @@ void StateManager::setState(int s)
stateLock.notifyAll();
}
+bool StateManager::setState(int s, int expected)
+{
+ Monitor::ScopedLock l(stateLock);
+ if (state == expected) {
+ state = s;
+ stateLock.notifyAll();
+ return true;
+ } else {
+ return false;
+ }
+}
+
int StateManager::getState() const
{
Monitor::ScopedLock l(stateLock);