SObjectizer-5 Extra
so_5::extra::mboxes::first_last_subscriber_notification::msg_first_subscriber Struct Referencefinal

Signal to be sent when the first subscriber arrives. More...

#include <first_last_subscriber_notification.hpp>

Inheritance diagram for so_5::extra::mboxes::first_last_subscriber_notification::msg_first_subscriber:

Detailed Description

Signal to be sent when the first subscriber arrives.

Usage example:

class my_producer final : public so_5::agent_t
{
public:
// Message with published data.
struct msg_data final : public so_5::message_t {...};
private:
state_t st_no_consumers{ this };
state_t st_consumers_waiting{ this };
...
const so_5::mbox_t publishing_mbox_;
...
public:
my_producer( context_t ctx )
: so_5::agent_t{ std::move(ctx) }
// New mbox for publishing produced data has to be created.
, publishing_mbox_{ mbox_ns::make<msg_data>(
so_environment(),
// agent's direct mbox as the target for notifications.
so_direct_mbox(),
so_5::mbox_type_t::multi_producer_multi_consumer )
}
{...}
void so_define_agent() override
{
st_consumers_waiting
.on_enter{ turn_data_acquisition_on(); }
.on_exit{ turn_data_acquisition_off(); }
.event( &my_producer::evt_last_subscriber )
;
st_no_consumers
.event( &my_producer::evt_first_subscriber )
;
...
st_no_consumers.activate();
}
...
private:
void evt_first_subscriber( mhood_t< msg_first_subscriber > )
{
st_consumers_waiting.activate();
}
void evt_last_subscriber( mhood_t< msg_last_subscriber > )
{
st_no_consumers.activate();
}
...
};
Since
v.1.5.2

Definition at line 135 of file first_last_subscriber_notification.hpp.


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