**Unsettled API** - A context for thread-safe execution of work. More...
#include <work_queue.hpp>
Public Member Functions | |
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 `protonconnection` are called in sequence. The connection's `protonwork_queue` allows you to "inject" extra work from any thread and have it executed in the same sequence.
You may also create arbitrary `protonwork_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 `protonwork` class represents the work to be queued and can be created from a function that takes no parameters and returns no value.
broker.cpp, multithreaded_client.cpp, multithreaded_client_flow_control.cpp, scheduled_send.cpp, and scheduled_send_03.cpp.
work_queue | ( | ) |
**Unsettled API** - Create a work queue.
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.
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.