|
| bool | closed () const |
| |
| void | close (bool soft=true) |
| | st::channel is set to the closed state More...
|
| |
| std::size_t | blocked_receivers () const |
| |
| bool | recv (st::message &msg) |
| | receive a message over the channel More...
|
| |
| state | try_recv (st::message &msg) |
| | do a non-blocking message receive over the channel More...
|
| |
| std::size_t | queued () const |
| |
| template<typename... As> |
| bool | send (As &&... as) |
| | send an st::message with given parameters into the internal message queue More...
|
| |
| iterator | begin () const |
| |
| iterator | end () const |
| |
| template<typename F , typename... As> |
| bool | async (std::size_t resp_id, F &&f, As &&... as) |
| | asynchronously execute user Callable on a system thread More...
|
| |
| template<class Rep , class Period , typename P > |
| bool | timer (std::size_t resp_id, const std::chrono::duration< Rep, Period > &timeout, P &&payload) |
| | start a timer More...
|
| |
| template<class Rep , class Period > |
| bool | timer (std::size_t resp_id, const std::chrono::duration< Rep, Period > &timeout) |
| | start a timer More...
|
| |
Interthread message passing queue.
The internal mechanism used by this library to communicate between system threads.
All methods in this object are threadsafe.
template<typename F , typename... As>
| bool st::channel::async |
( |
std::size_t |
resp_id, |
|
|
F && |
f, |
|
|
As &&... |
as |
|
) |
| |
|
inline |
asynchronously execute user Callable on a system thread
Internally calls std::async to asynchronously execute user function (Callable). This behavior is useful for evaluating long running functions in a way that will not block the current thread. Additionally, the internal usage of std::async() allows for optimizations made by the standard library when launching temporary worker threads.
The resulting st::message's st::message::id() will equal the value of argument resp_id.
If the user function returns no value, then st::message::data() will be unallocated. Otherwise, st::message::data() will contain the value returned by Callable f.
- Parameters
-
| resp_id | of the message that will be sent back to the this st::channel when std::async completes |
| f | a Callable to execute on another system thread |
| as | optional arguments for f |
- Returns
true if the asynchronous call was scheduled, false if this st::channel is closed
receive a message over the channel
This is a blocking operation that will not complete until there is a message available in the message queue, after which the argument message reference will be overwritten by the front of the queue. The front of the queue will then be popped.
This will return early if st::channel::close(false) is called. If st::channel::close(true) or st::channel::close() is called instead, then calls to this function will succeed until the internal message queue is empty.
Multiple simultaneous recv() calls will be served in the order they were called.
- Parameters
-
| msg | interprocess message object reference to contain the received message |
- Returns
true on success, false if channel is closed