Unsettled API - A context for thread-safe execution of work. More...
#include <work_queue.hpp>
Public Member Functions | |
work_queue () | |
Unsettled API - Create a work queue. | |
work_queue (container &) | |
Unsettled API - Create a work queue backed by a container. | |
bool | add (work fn) |
Unsettled API - Add work fn to the work queue. | |
bool | add (void_function0 &fn) |
Deprecated - Use add(work) . | |
void | schedule (duration, work fn) |
Unsettled API - Add work fn to the work queue after a duration. | |
void | schedule (duration, void_function0 &fn) |
Deprecated - Use schedule(duration, work) . | |
Unsettled API - A context for thread-safe execution of work.
Event-handler functions associated with a single proton::connection
are called in sequence. The connection's proton::work_queue
allows you to "inject" extra work from any thread and have it executed in the same sequence.
You may also create arbitrary proton::work_queue
objects backed by a container that allow other objects to have their own serialised work queues that can have work injected safely from other threads. The container ensures that the work is correctly serialised.
The proton::work
class represents the work to be queued and can be created from a function that takes no parameters and returns no value.
bool add | ( | work | fn | ) |
Unsettled API - Add work fn
to the work queue.
Work fn
will be called serially with other work in the queue. The work may be deferred and executed in another thread.
fn
has been or will be called; false if the event loops is ended or fn
cannot be injected for any other reason. void schedule | ( | duration | , |
work | fn | ||
) |
Unsettled API - Add work fn
to the work queue after a duration.
Scheduled execution is "best effort". It may not be possible to inject the work after the elapsed duration. There will be no indication of this.
Work fn
will be called serially with other work in the queue. The work may be deferred and executed in another thread.
fn
has been or will be called; false if the event loops is ended or fn
cannot be injected for any other reason.