diff options
author | Ted Ross <tross@apache.org> | 2009-09-15 17:45:51 +0000 |
---|---|---|
committer | Ted Ross <tross@apache.org> | 2009-09-15 17:45:51 +0000 |
commit | 1e0e8ae7d1792f1deff8089d4c26075b9a142cdd (patch) | |
tree | 982fc02c3faaef6c7a361af531a39837c42c1884 /qpid/cpp/src/qmf/SequenceManager.cpp | |
parent | c9346545c9fa32a1e124d1842a91ad1b4588e29a (diff) | |
download | qpid-python-1e0e8ae7d1792f1deff8089d4c26075b9a142cdd.tar.gz |
QMF Console updated to the point where query (get_object) is supported.
The Ruby binding continues to track the c++ engine progress.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@815416 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qmf/SequenceManager.cpp')
-rw-r--r-- | qpid/cpp/src/qmf/SequenceManager.cpp | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/qpid/cpp/src/qmf/SequenceManager.cpp b/qpid/cpp/src/qmf/SequenceManager.cpp index f51ce9d8b8..3171e66fac 100644 --- a/qpid/cpp/src/qmf/SequenceManager.cpp +++ b/qpid/cpp/src/qmf/SequenceManager.cpp @@ -25,26 +25,72 @@ using namespace qpid::sys; SequenceManager::SequenceManager() : nextSequence(1) {} -uint32_t SequenceManager::reserve(SequenceContext* ctx) +void SequenceManager::setUnsolicitedContext(SequenceContext::Ptr ctx) +{ + unsolicitedContext = ctx; +} + +uint32_t SequenceManager::reserve(SequenceContext::Ptr ctx) { Mutex::ScopedLock _lock(lock); + if (ctx.get() == 0) + ctx = unsolicitedContext; uint32_t seq = nextSequence; while (contextMap.find(seq) != contextMap.end()) seq = seq < 0xFFFFFFFF ? seq + 1 : 1; nextSequence = seq < 0xFFFFFFFF ? seq + 1 : 1; contextMap[seq] = ctx; + ctx->reserve(); return seq; } void SequenceManager::release(uint32_t sequence) { Mutex::ScopedLock _lock(lock); - map<uint32_t, SequenceContext*>::iterator iter = contextMap.find(sequence); + + if (sequence == 0) { + if (unsolicitedContext.get() != 0) + unsolicitedContext->release(); + return; + } + + map<uint32_t, SequenceContext::Ptr>::iterator iter = contextMap.find(sequence); if (iter != contextMap.end()) { if (iter->second != 0) - iter->second->complete(); + iter->second->release(); contextMap.erase(iter); } } +void SequenceManager::releaseAll() +{ + Mutex::ScopedLock _lock(lock); + contextMap.clear(); +} + +void SequenceManager::dispatch(uint8_t opcode, uint32_t sequence, qpid::framing::Buffer& buffer) +{ + Mutex::ScopedLock _lock(lock); + bool done; + + if (sequence == 0) { + if (unsolicitedContext.get() != 0) { + done = unsolicitedContext->handleMessage(opcode, sequence, buffer); + if (done) + unsolicitedContext->release(); + } + return; + } + + map<uint32_t, SequenceContext::Ptr>::iterator iter = contextMap.find(sequence); + if (iter != contextMap.end()) { + if (iter->second != 0) { + done = iter->second->handleMessage(opcode, sequence, buffer); + if (done) { + iter->second->release(); + contextMap.erase(iter); + } + } + } +} |