diff options
Diffstat (limited to 'cpp/include/qpid/messaging')
-rw-r--r-- | cpp/include/qpid/messaging/Duration.h | 19 | ||||
-rw-r--r-- | cpp/include/qpid/messaging/Receiver.h | 8 | ||||
-rw-r--r-- | cpp/include/qpid/messaging/Session.h | 4 |
3 files changed, 21 insertions, 10 deletions
diff --git a/cpp/include/qpid/messaging/Duration.h b/cpp/include/qpid/messaging/Duration.h index 5f95acf04d..a127e86f29 100644 --- a/cpp/include/qpid/messaging/Duration.h +++ b/cpp/include/qpid/messaging/Duration.h @@ -22,7 +22,6 @@ * */ #include "qpid/sys/IntegerTypes.h" -#include <limits> namespace qpid { namespace messaging { @@ -30,9 +29,21 @@ namespace messaging { /** * A duration is a time in milliseconds. */ -typedef uint64_t Duration; -const Duration INFINITE_DURATION = std::numeric_limits<uint64_t>::max(); -const Duration DURATION_SEC = 1000; +class Duration +{ + public: + explicit Duration(uint64_t milliseconds); + uint64_t getMilliseconds() const; + static const Duration INFINITE; + static const Duration IMMEDIATE; + static const Duration SECOND; + static const Duration MINUTE; + private: + uint64_t milliseconds; +}; + +Duration operator*(const Duration& duration, uint64_t multiplier); +Duration operator*(uint64_t multiplier, const Duration& duration); }} // namespace qpid::messaging diff --git a/cpp/include/qpid/messaging/Receiver.h b/cpp/include/qpid/messaging/Receiver.h index 80b58106d7..f0b9a7d66e 100644 --- a/cpp/include/qpid/messaging/Receiver.h +++ b/cpp/include/qpid/messaging/Receiver.h @@ -53,7 +53,7 @@ class Receiver : public qpid::messaging::Handle<ReceiverImpl> * available. Returns false if there is no message to give after * waiting for the specified timeout. */ - QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=Duration::INFINITE); /** * Retrieves a message from this receivers local queue, or waits * for up to the specified timeout for a message to become @@ -62,7 +62,7 @@ class Receiver : public qpid::messaging::Handle<ReceiverImpl> *@exception NoMessageAvailable if there is no message to give * after waiting for the specified timeout. */ - QPID_CLIENT_EXTERN Message get(Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN Message get(Duration timeout=Duration::INFINITE); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -70,7 +70,7 @@ class Receiver : public qpid::messaging::Handle<ReceiverImpl> * that there is no message for the subscription this receiver is * serving before returning false. */ - QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN bool fetch(Message& message, Duration timeout=Duration::INFINITE); /** * Retrieves a message for this receivers subscription or waits * for up to the specified timeout for one to become @@ -81,7 +81,7 @@ class Receiver : public qpid::messaging::Handle<ReceiverImpl> *@exception NoMessageAvailable if there is no message to give * after waiting for the specified timeout. */ - QPID_CLIENT_EXTERN Message fetch(Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN Message fetch(Duration timeout=Duration::INFINITE); /** * Sets the capacity for the receiver. The capacity determines how * many incoming messages can be held in the receiver before being diff --git a/cpp/include/qpid/messaging/Session.h b/cpp/include/qpid/messaging/Session.h index 032b678c5c..bc5aaed6ba 100644 --- a/cpp/include/qpid/messaging/Session.h +++ b/cpp/include/qpid/messaging/Session.h @@ -102,7 +102,7 @@ class Session : public qpid::messaging::Handle<SessionImpl> * which case the passed in receiver reference will be set to the * receiver for that message or false if no message was available. */ - QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=Duration::INFINITE); /** * Returns the receiver for the next available message. If there * are no available messages at present the call will block for up @@ -111,7 +111,7 @@ class Session : public qpid::messaging::Handle<SessionImpl> *@exception Receiver::NoMessageAvailable if no message became available in * time. */ - QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=INFINITE_DURATION); + QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=Duration::INFINITE); /** * Create a new sender through which messages can be sent to the |