From 2dff9493ceb62d37a3b70a4abd6bc0539bdb581e Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 27 Jan 2009 21:17:47 +0000 Subject: Producer side rate throttling: This uses the Message.Flow command to send credit from broker to client to ensure that the client doesn't exceed a rate configured on the broker per session. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@738247 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/Semaphore.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid/sys') diff --git a/cpp/src/qpid/sys/Semaphore.h b/cpp/src/qpid/sys/Semaphore.h index 3efb7ce2df..af937b60b8 100644 --- a/cpp/src/qpid/sys/Semaphore.h +++ b/cpp/src/qpid/sys/Semaphore.h @@ -51,10 +51,22 @@ public: count--; } + void release(uint n) + { + Monitor::ScopedLock l(monitor); + if (count==0) monitor.notifyAll(); + count+=n; + } + void release() + { + release(1); + } + + void forceLock() { Monitor::ScopedLock l(monitor); - if (!count++) monitor.notifyAll(); + count = 0; } private: -- cgit v1.2.1