Health-GPS
1.2.2.0
Global Health Policy Simulation model (Health-GPS)
|
Thread-safe communication channel data type. More...
#include <channel.h>
Public Types | |
using | value_type = T |
using | size_type = std::size_t |
Public Member Functions | |
Channel (size_type capacity=0) | |
Initialises a new instance of the Channel class. More... | |
Channel (const Channel &)=delete | |
Channel & | operator= (const Channel &)=delete |
Channel (Channel &&)=delete | |
Channel & | operator= (Channel &&)=delete |
virtual | ~Channel ()=default |
Destroys a Channel instance. More... | |
bool | send (const value_type &message) |
Sends a new message through the channel by reference. More... | |
bool | send (value_type &&message) |
Sends a new message through the channel. More... | |
std::optional< value_type > | try_receive (int timeout_millis=0) |
Try to receive a message from the channel. More... | |
constexpr size_type | size () const noexcept |
Gets the current channel size, number of messages. More... | |
constexpr bool | empty () const noexcept |
Determine whether the channel is empty. More... | |
void | close () noexcept |
Close the channel, no new messages are accepted. More... | |
bool | closed () const noexcept |
Determine whether the channel is closed. More... | |
Thread-safe communication channel data type.
This channel has been designed specific to enable in-memory communication from the baseline to the intervention scenarios simulations. This is a hard modelling requirement, non-memory communication such as data streaming might offer more scalable alternative, including the option of running a single baseline and multiple interventions in parallel.
T | The channel data type |
using hgps::Channel< T >::size_type = std::size_t |
using hgps::Channel< T >::value_type = T |
|
inlineexplicit |
Initialises a new instance of the Channel class.
capacity | The channel capacity, if fixed; otherwise, unlimited |
|
delete |
|
delete |
|
virtualdefault |
Destroys a Channel instance.
|
inlinenoexcept |
Close the channel, no new messages are accepted.
|
inlinenoexcept |
Determine whether the channel is closed.
|
inlineconstexprnoexcept |
Determine whether the channel is empty.
|
delete |
|
delete |
|
inline |
Sends a new message through the channel by reference.
message | The message instance to send |
|
inline |
Sends a new message through the channel.
message | The message instance to send |
|
inlineconstexprnoexcept |
Gets the current channel size, number of messages.
|
inline |
Try to receive a message from the channel.
timeout_millis | Max wait timeout, or zero for infinity |