diff options
| author | Gordon Sim <gsim@apache.org> | 2014-08-19 17:42:46 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2014-08-19 17:42:46 +0000 |
| commit | 7520eb94cd61b4ae3d31879102791182210a5302 (patch) | |
| tree | e525b405ad2674b3f4b64e246e774bd6097c44b4 /qpid/cpp/src | |
| parent | 396550e30679b2daa7c41d3f346fdaceabf85bde (diff) | |
| download | qpid-python-7520eb94cd61b4ae3d31879102791182210a5302.tar.gz | |
QPID-6021: avoid waking up the io thread unnecessarily, improves receive rate a bit
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1618914 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp | 6 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp | 12 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp index 5aba00fc50..e08b387e85 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp @@ -272,7 +272,11 @@ bool ConnectionContext::get(boost::shared_ptr<SessionContext> ssn, boost::shared pn_link_advance(lnk->receiver); if (lnk->capacity) { pn_link_flow(lnk->receiver, 1); - wakeupDriver();//TODO: wakeup less frequently + if (lnk->wakeupToIssueCredit()) { + wakeupDriver(); + } else { + haveOutput = true; + } } return true; } else if (until > qpid::sys::now()) { diff --git a/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp b/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp index 7eaa1c068b..08cc130a9e 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.cpp @@ -36,7 +36,7 @@ ReceiverContext::ReceiverContext(pn_session_t* session, const std::string& n, co address(a), helper(address), receiver(pn_receiver(session, name.c_str())), - capacity(0) {} + capacity(0), used(0) {} ReceiverContext::~ReceiverContext() { //pn_link_free(receiver); @@ -125,4 +125,14 @@ bool ReceiverContext::hasCurrent() return pn_link_current(receiver); } +bool ReceiverContext::wakeupToIssueCredit() +{ + if (++used >= (capacity/2)) { + used = 0; + return true; + } else { + return false; + } +} + }}} // namespace qpid::messaging::amqp diff --git a/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h b/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h index d185ae3146..2b4e8e1986 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h +++ b/qpid/cpp/src/qpid/messaging/amqp/ReceiverContext.h @@ -67,8 +67,10 @@ class ReceiverContext AddressHelper helper; pn_link_t* receiver; uint32_t capacity; + uint32_t used; qpid::sys::AtomicCount fetching; void configure(pn_terminus_t*); + bool wakeupToIssueCredit(); }; }}} // namespace qpid::messaging::amqp |
