Qpid Proton C++ API  0.18.0
work_queue

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

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

Member Function Documentation

◆ add()

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.
Examples:
broker.cpp, multithreaded_client.cpp, multithreaded_client_flow_control.cpp, and scheduled_send.cpp.

◆ schedule()

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.
Examples:
scheduled_send_03.cpp.

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