Inter-thread communication primitive to send messages between threads Has a growable Queue.
More...
|
Result< void, AllocationError > | init (Allocator &alloc, size_t initCapacity=10) |
| Initializes a new message Queue.
|
|
void | deinit (Allocator &alloc) |
| Cleans up memory Note: All references to the inbox MUST be cleaned up BEFORE calling this method.
|
|
void | close () |
| Closes an inbox.
|
|
Result< void, ChannelTrySendErrors > | try_send (const T &msg) |
| Send message without blocking Will NOT grow inbox Queue and will instead fail.
|
|
Result< void, ChannelSendBlockErrors > | send_block (const T &msg) |
| Send message, will block indefinitely Will NOT grow inbox Queue and will instead block.
|
|
template<typename Clock = std::chrono::steady_clock, typename Duration> |
Result< void, ChannelSendBeforeErrors > | send_before (const T &msg, const std::chrono::time_point< Clock, Duration > &when) |
| Send message before a timeout Will NOT grow inbox Queue and will instead block.
|
|
Result< void, ChannelGrowTrySendErrors > | try_send (Allocator &alloc, const T &msg) |
| Send message without blocking Will grow inbox Queue if needed If unable to grow, will return an error.
|
|
Result< void, ChannelGrowSendBlockErrors > | send_block (Allocator &alloc, const T &msg) |
| Send message and block indefinitely Will grow inbox Queue if needed If unable to grow, will instead block.
|
|
template<typename Clock = std::chrono::steady_clock, typename Duration> |
Result< void, ChannelGrowSendBeforeErrors > | send_before (Allocator &alloc, const T &msg, const std::chrono::time_point< Clock, Duration > &when) |
| Send message before a timeout Will grow inbox Queue if needed If unable to grow, will instead block.
|
|
Result< Optional< T >, ChannelTryReceiveErrors > | try_receive () |
| Tries to receive a message Will fail if it would have to block If the channel is empty and closed, will return nullopt instead of a message.
|
|
Optional< T > | receive_block () |
| Receives a message from the channel Blocks indefinitely.
|
|
template<typename Clock, typename Duration> |
Result< Optional< T >, ChannelSendBeforeErrors > | receive_before (const std::chrono::time_point< Clock, Duration > &when) |
| Receives a message before a time point Blocks until a time point.
|
|
bool | is_initialized () const noexcept |
| Checks if the inbox is initialized inboxes which aren't initialized will abort if used.
|
|
void | shrinkToFit (Allocator &alloc) |
| Shrinks Queue to fit current Queue size Useful to lower memory usage.
|
|
template<typename T>
struct mtcore::thread::Inbox< T >
Inter-thread communication primitive to send messages between threads Has a growable Queue.
Locks:
- 1 for entire data structure
Condition Variables:
- 2 condition variables (one to send, one to receive)
Non-Blocking Availability:
- Template Parameters
-
T | Type of messages to send |
Definition at line 75 of file inbox.hpp.