SObjectizer-5 Extra
Namespaces | Classes | Functions
so_5::extra::revocable_msg Namespace Reference

Namespaces

 details
 
 errors
 
 impl
 

Classes

class  delivery_id_t
 The ID of revocable message/signal. More...
 

Functions

template<typename Message , typename Target , typename... Args>
SO_5_NODISCARD delivery_id_t send (Target &&to, Args &&... args)
 A utility function for creating and delivering a revocable message. More...
 
template<typename Message , typename Target >
SO_5_NODISCARD std::enable_if< !::so_5::is_signal< Message >::value, delivery_id_t >::type send (Target &&to, mhood_t< Message > cmd)
 A helper function for redirection of an existing message as a revocable one. More...
 
template<typename Message , typename Target >
SO_5_NODISCARD std::enable_if< ::so_5::is_signal< Message >::value, delivery_id_t >::type send (Target &&to, mhood_t< Message >)
 A helper function for redirection of an existing signal as a revocable one. More...
 

Function Documentation

◆ send() [1/3]

template<typename Message , typename Target , typename... Args>
SO_5_NODISCARD delivery_id_t so_5::extra::revocable_msg::send ( Target &&  to,
Args &&...  args 
)

A utility function for creating and delivering a revocable message.

This function can be used for sending messages and signals to mboxes and mchains, and to the direct mboxes of agents and ad-hoc agents.

Message/signal sent can be revoked by using delivery_id_t::revoke() method:

auto id = so_5::extra::revocable_msg::send<my_message>(...);
...
id.revoke();

Please note that revoked message is not removed from queues where it wait for processing. But revoked message/signal will be ignored just after extraction from a queue.

Usage examples:

namespace delivery_ns = so_5::extra::revocable_msg;
// Send a revocable message to mbox mb1.
so_5::mbox_t mb1 = ...;
auto id1 = delivery_ns::send<my_message>(mb1, ...);
// Send a revocable message to mchain ch1 and revoke it after some time.
so_5::mchain_t ch1 = ...;
auto id2 = delivery_ns::send<my_message>(ch1, ...);
...
id2.revoke();
// Send a revocable message to the direct mbox of agent a1.
so_5::agent_t & a1 = ...;
auto id3 = delivery_ns::send<my_message>(a1, ...);
Note
The return value of that function must be stored somewhere. Otherwise the revocable message will be revoked automatically just right after send() returns.
Since
v.1.2.0
Parameters
toTarget for the message. Can be a reference to mbox, mchain, agent or ad-hod agent.
argsMessage constructor parameters.

Definition at line 419 of file pub.hpp.

◆ send() [2/3]

template<typename Message , typename Target >
SO_5_NODISCARD std::enable_if< !::so_5::is_signal< Message >::value, delivery_id_t >::type so_5::extra::revocable_msg::send ( Target &&  to,
mhood_t< Message >  cmd 
)

A helper function for redirection of an existing message as a revocable one.

Usage example:

class my_agent : public so_5::agent_t {
...
...
void on_some_event(mhood_t<my_message> cmd) {
... // Some processing.
// Redirection to another destination.
id_ = so_5::extra::revocable_msg::send(another_mbox_, cmd);
}
};
Note
The return value of that function must be stored somewhere. Otherwise the revocable message will be revoked automatically just right after send() returns.
Since
v.1.2.0
Parameters
toTarget for the message. Can be a reference to mbox, mchain, agent or ad-hod agent.
cmdMessage to be delivered.

Definition at line 463 of file pub.hpp.

◆ send() [3/3]

template<typename Message , typename Target >
SO_5_NODISCARD std::enable_if< ::so_5::is_signal< Message >::value, delivery_id_t >::type so_5::extra::revocable_msg::send ( Target &&  to,
mhood_t< Message >   
)

A helper function for redirection of an existing signal as a revocable one.

This function can be useful in template classes where it is unknown is template parameter message of signal.

Usage example:

template<typename Msg>
class my_agent : public so_5::agent_t {
...
...
void on_some_event(mhood_t<Msg> cmd) {
... // Some processing.
// Redirection to another destination.
id_ = so_5::extra::revocable_msg::send(another_mbox_, cmd);
}
};
Note
The return value of that function must be stored somewhere. Otherwise the revocable message will be revoked automatically just right after send() returns.
Since
v.1.2.0
Parameters
toTarget for the message. Can be a reference to mbox, mchain, agent or ad-hod agent.

Definition at line 512 of file pub.hpp.