Add ServiceQueue::wrap

This commit is contained in:
Vinnie Falco
2013-10-04 19:02:33 -07:00
parent 6c7f5d093c
commit 2c3ead339e
5 changed files with 471 additions and 3 deletions

View File

@@ -27,6 +27,8 @@
#include "ThreadLocalValue.h"
#include "WaitableEvent.h"
#include "detail/DispatchedHandler.h"
namespace beast {
namespace detail {
@@ -518,6 +520,15 @@ public:
ItemType <Handler> (BEAST_MOVE_CAST(Handler)(handler)));
}
/** Return a new handler that dispatches the wrapped handler on the queue. */
template <typename Handler>
detail::DispatchedHandler <ServiceQueueType&, Handler> wrap (
BEAST_MOVE_ARG(Handler) handler)
{
return detail::DispatchedHandler <ServiceQueueType&, Handler> (
*this, BEAST_MOVE_CAST(Handler)(handler));
}
/** Run the event loop to execute ready handlers.
This runs handlers that are ready to run, without blocking, until
there are no more handlers ready or the service queue has been stopped.