diff options
| author | Gordon Sim <gsim@apache.org> | 2010-03-03 17:06:44 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2010-03-03 17:06:44 +0000 |
| commit | 2a71aa199010c48608f6d63794f52ad2e7afede5 (patch) | |
| tree | c75a9248e0ced59974bde18a73f5237f5efb8446 /cpp/src/qpid/client/amqp0_10/SessionImpl.cpp | |
| parent | 589def015a6567ecb7be9fe2af0ebec662cea56c (diff) | |
| download | qpid-python-2a71aa199010c48608f6d63794f52ad2e7afede5.tar.gz | |
QPID-2402 & QPID-2406: Documented the units for the ttl property of Message. Eliminated use of qpid::sys::Duration from API.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@918575 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client/amqp0_10/SessionImpl.cpp')
| -rw-r--r-- | cpp/src/qpid/client/amqp0_10/SessionImpl.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp index 62af6394b0..9823dba6e1 100644 --- a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp +++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp @@ -266,24 +266,33 @@ bool SessionImpl::accept(ReceiverImpl* receiver, } } -bool SessionImpl::getIncoming(IncomingMessages::Handler& handler, qpid::sys::Duration timeout) +qpid::sys::Duration adjust(qpid::messaging::Duration timeout) { - return incoming.get(handler, timeout); + if (timeout < (uint64_t) (qpid::sys::TIME_INFINITE/qpid::sys::TIME_MSEC)) { + return timeout * qpid::sys::TIME_MSEC; + } else { + return qpid::sys::TIME_INFINITE; + } +} + +bool SessionImpl::getIncoming(IncomingMessages::Handler& handler, qpid::messaging::Duration timeout) +{ + return incoming.get(handler, adjust(timeout)); } -bool SessionImpl::get(ReceiverImpl& receiver, qpid::messaging::Message& message, qpid::sys::Duration timeout) +bool SessionImpl::get(ReceiverImpl& receiver, qpid::messaging::Message& message, qpid::messaging::Duration timeout) { IncomingMessageHandler handler(boost::bind(&SessionImpl::accept, this, &receiver, &message, _1)); return getIncoming(handler, timeout); } -bool SessionImpl::nextReceiver(qpid::messaging::Receiver& receiver, qpid::sys::Duration timeout) +bool SessionImpl::nextReceiver(qpid::messaging::Receiver& receiver, qpid::messaging::Duration timeout) { qpid::sys::Mutex::ScopedLock l(lock); while (true) { try { std::string destination; - if (incoming.getNextDestination(destination, timeout)) { + if (incoming.getNextDestination(destination, adjust(timeout))) { Receivers::const_iterator i = receivers.find(destination); if (i == receivers.end()) { throw qpid::Exception(QPID_MSG("Received message for unknown destination " << destination)); @@ -300,7 +309,7 @@ bool SessionImpl::nextReceiver(qpid::messaging::Receiver& receiver, qpid::sys::D } } -qpid::messaging::Receiver SessionImpl::nextReceiver(qpid::sys::Duration timeout) +qpid::messaging::Receiver SessionImpl::nextReceiver(qpid::messaging::Duration timeout) { qpid::messaging::Receiver receiver; if (!nextReceiver(receiver, timeout)) throw Receiver::NoMessageAvailable(); |
