work_queue Class Reference

**Unsettled API** - A context for thread-safe execution of work. More...

#include <work_queue.hpp>

List of all members.

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)`.

Detailed Description

**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.

Examples:

broker.cpp, multithreaded_client.cpp, multithreaded_client_flow_control.cpp, scheduled_send.cpp, and scheduled_send_03.cpp.


Constructor & Destructor Documentation

work_queue (  ) 

**Unsettled API** - Create a work queue.


Member Function Documentation

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.

Returns:
true if `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.

Returns:
true if `fn` has been or will be called; false if the event loops is ended or `fn` cannot be injected for any other reason.


The documentation for this class was generated from the following file:

Generated on 8 Oct 2019 for Qpid Proton C++ by  doxygen 1.6.1