SObjectizer-5 Extra
Loading...
Searching...
No Matches
so_5::extra::mboxes::first_last_subscriber_notification Namespace Reference

Namespaces

namespace  details
 
namespace  errors
 

Classes

struct  msg_first_subscriber
 Signal to be sent when the first subscriber arrives. More...
 
struct  msg_last_subscriber
 Signal to be sent when the last subscriber gone. More...
 

Functions

template<typename Msg_Type , typename Lock_Type = std::mutex>
mbox_t make_mbox (environment_t &env, mbox_t notification_mbox, mbox_type_t mbox_type)
 Create an instance of first_last_subscriber_notification mbox.
 
template<typename Msg_Type , typename Lock_Type = std::mutex>
mbox_t make_multi_consumer_mbox (environment_t &env, mbox_t notification_mbox)
 Create an instance of first_last_subscriber_notification MPMC mbox.
 
template<typename Msg_Type , typename Lock_Type = std::mutex>
mbox_t make_single_consumer_mbox (environment_t &env, mbox_t notification_mbox)
 Create an instance of first_last_subscriber_notification MPSC mbox.
 

Function Documentation

◆ make_mbox()

template<typename Msg_Type , typename Lock_Type = std::mutex>
mbox_t so_5::extra::mboxes::first_last_subscriber_notification::make_mbox ( environment_t & env,
mbox_t notification_mbox,
mbox_type_t mbox_type )
nodiscard

Create an instance of first_last_subscriber_notification mbox.

Usage examples:

Create a MPMC mbox with std::mutex as Lock_Type (this mbox can safely be used in multi-threaded environments):

so_5::environment_t & env = ...;
auto notification_mbox = env.create_mbox();
auto mbox = mbox_ns::make_mbox<my_message>(
env,
notification_mbox,
so_5::mbox_type_t::multi_producer_multi_consumer);

Create a MPSC mbox with std::mutex as Lock_Type (this mbox can safely be used in multi-threaded environments):

so_5::environment_t & env = ...;
auto notification_mbox = env.create_mbox();
auto mbox = mbox_ns::make_mbox<my_message>(
env,
notification_mbox,
so_5::mbox_type_t::multi_producer_single_consumer);

Create a MPMC mbox with so_5::null_mutex_t as Lock_Type (this mbox can only be used in single-threaded environments):

so_5::environment_t & env = ...;
auto notification_mbox = env.create_mbox();
auto mbox = mbox_ns::make_mbox<my_message, so_5::null_mutex_t>(
env,
notification_mbox,
so_5::mbox_type_t::multi_producer_multi_consumer);
Attention
This type of mbox terminates the whole application if an attempt to send a notification (in form of msg_first_subscriber and msg_last_subscriber signals) throws.
Template Parameters
Msg_Typetype of message to be used with a new mbox.
Lock_Typetype of lock to be used for thread safety. It can be std::mutex or so_5::null_mutex_t (or any other type which can be used with std::lock_quard).
Since
v.1.5.2
Parameters
envSObjectizer Environment to work in.
notification_mboxMbox for notifications about the first/last subscriber.
mbox_typeType of this mbox (MPSC or MPMC).

Definition at line 704 of file first_last_subscriber_notification.hpp.

◆ make_multi_consumer_mbox()

template<typename Msg_Type , typename Lock_Type = std::mutex>
mbox_t so_5::extra::mboxes::first_last_subscriber_notification::make_multi_consumer_mbox ( environment_t & env,
mbox_t notification_mbox )
nodiscard

Create an instance of first_last_subscriber_notification MPMC mbox.

Usage examples:

Create a MPMC mbox with std::mutex as Lock_Type (this mbox can safely be used in multi-threaded environments):

so_5::environment_t & env = ...;
auto notification_mbox = env.create_mbox();
auto mbox = mbox_ns::make_multi_consumer_mbox<my_message>(
env,
notification_mbox);
Note
It's just a thin wrapper around make_mbox() template function.
See also
make_mbox
Since
v.1.5.2
Parameters
envSObjectizer Environment to work in.
notification_mboxMbox for notifications about the first/last subscriber.

Definition at line 781 of file first_last_subscriber_notification.hpp.

◆ make_single_consumer_mbox()

template<typename Msg_Type , typename Lock_Type = std::mutex>
mbox_t so_5::extra::mboxes::first_last_subscriber_notification::make_single_consumer_mbox ( environment_t & env,
mbox_t notification_mbox )
nodiscard

Create an instance of first_last_subscriber_notification MPSC mbox.

Usage examples:

Create a MPSC mbox with std::mutex as Lock_Type (this mbox can safely be used in multi-threaded environments):

so_5::environment_t & env = ...;
auto notification_mbox = env.create_mbox();
auto mbox = mbox_ns::make_single_consumer_mbox<my_message>(
env,
notification_mbox);
Note
It's just a thin wrapper around make_mbox() template function.
See also
make_mbox
Since
v.1.5.2
Parameters
envSObjectizer Environment to work in.
notification_mboxMbox for notifications about the first/last subscriber.

Definition at line 824 of file first_last_subscriber_notification.hpp.