diff options
author | Alan Conway <aconway@apache.org> | 2008-09-06 00:34:58 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-09-06 00:34:58 +0000 |
commit | 3bb7782cb0904f0abf61b7fb28da7bce905ceb08 (patch) | |
tree | fcd641905882a5a5bc7a3f6fa8f621b9f15154ce /cpp/src/qpid/cluster/PollableQueue.h | |
parent | df334f0768c628f2fed8dd350c135d914c54b918 (diff) | |
download | qpid-python-3bb7782cb0904f0abf61b7fb28da7bce905ceb08.tar.gz |
Queue cpg deliveries for execution in separate thread.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@692595 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/cluster/PollableQueue.h')
-rw-r--r-- | cpp/src/qpid/cluster/PollableQueue.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cpp/src/qpid/cluster/PollableQueue.h b/cpp/src/qpid/cluster/PollableQueue.h index 74da2df750..1c7720f5c6 100644 --- a/cpp/src/qpid/cluster/PollableQueue.h +++ b/cpp/src/qpid/cluster/PollableQueue.h @@ -27,6 +27,7 @@ #include "qpid/sys/Mutex.h" #include <boost/function.hpp> #include <boost/bind.hpp> +#include <algorithm> #include <deque> namespace qpid { @@ -53,6 +54,15 @@ class PollableQueue { /** Callback to process a range of items. */ typedef boost::function<void (const iterator&, const iterator&)> Callback; + /** Functor tempalate to create a Callback from a functor that handles a single item. */ + template <class F> struct ForEach { + F handleOne; + ForEach(const F& f) : handleOne(f) {} + void operator()(const iterator& i, const iterator& j) const { std::for_each(i, j, handleOne); } + }; + /** Function to create ForEach instances */ + template <class F> static ForEach<F> forEach(const F& f) { return ForEach<F>(f); } + /** When the queue is selected by the poller, values are passed to callback cb. */ explicit PollableQueue(const Callback& cb); |