|
template<typename Message , typename Target , typename... Args> |
SO_5_NODISCARD timer_id_t | send_periodic (Target &&target, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, Args &&... args) |
| A utility function for creating and delivering a periodic message to the specified destination. More...
|
|
template<typename Message > |
SO_5_NODISCARD std::enable_if< !::so_5::is_signal< Message >::value, timer_id_t >::type | send_periodic (const ::so_5::mbox_t &to, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, ::so_5::mhood_t< Message > mhood) |
| A utility function for delivering a periodic from an existing message hood. More...
|
|
template<typename Message > |
SO_5_NODISCARD std::enable_if< ::so_5::is_signal< Message >::value, timer_id_t >::type | send_periodic (const ::so_5::mbox_t &to, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, ::so_5::mhood_t< Message >) |
| A utility function for periodic redirection of a signal from existing message hood. More...
|
|
template<typename Message , typename Target > |
SO_5_NODISCARD timer_id_t | send_periodic (Target &&target, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, ::so_5::mhood_t< Message > mhood) |
| A helper function for redirection of a message/signal as a periodic message/signal. More...
|
|
template<typename Message , typename Target , typename... Args> |
SO_5_NODISCARD timer_id_t | send_delayed (Target &&target, std::chrono::steady_clock::duration pause, Args &&... args) |
| A utility function for creating and delivering a delayed message to the specified destination. More...
|
|
template<typename Message > |
SO_5_NODISCARD timer_id_t | send_delayed (const so_5::mbox_t &to, std::chrono::steady_clock::duration pause, ::so_5::mhood_t< Message > cmd) |
| A helper function for redirection of existing message/signal as delayed message. More...
|
|
template<typename Message , typename Target > |
SO_5_NODISCARD timer_id_t | send_delayed (Target &&target, std::chrono::steady_clock::duration pause, ::so_5::mhood_t< Message > cmd) |
| A helper function for redirection of existing message/signal as delayed message. More...
|
|
template<typename Message , typename Target , typename... Args>
SO_5_NODISCARD timer_id_t so_5::extra::revocable_timer::send_delayed |
( |
Target && |
target, |
|
|
std::chrono::steady_clock::duration |
pause, |
|
|
Args &&... |
args |
|
) |
| |
A utility function for creating and delivering a delayed message to the specified destination.
Agent, mbox or mchain can be used as target.
- Note
- Message chains with overload control must be used for periodic messages with additional care because exceptions can't be thrown during dispatching messages from timer.
Usage example 1:
class my_agent : public so_5::agent_t {
timer_ns::timer_id_t timer_;
...
void so_evt_start() override {
...
timer_ = timer_ns::send_periodic<kill_youself>(*this, 60s, ...);
...
}
...
};
Usage example 2:
so_5::wrapped_env_t sobj;
so_5::mbox_t worker_mbox = sobj.environment().introduce_coop(
[&](so_5::coop_t & coop) {
auto worker = coop.make_agent<worker_agent>(...);
worker_mbox = worker->so_direct_mbox();
});
auto timer_id = so_5::extra::revocable_timer::send_periodic<kill_yourself>(
worker_mbox(),
60s,
... );
...
timer_id.release();
- Note
- The return value of that function must be stored somewhere. Otherwise the delayed timer will be cancelled automatically just right after send_delayed returns.
- Attention
- Value of pause should be non-negative.
- Template Parameters
-
Message | type of message or signal to be sent. |
Target | can be so_5::agent_t, so_5::mbox_t or so_5::mchain_t. |
Args | list of arguments for Message's constructor. |
- Since
- v.1.2.0
- Parameters
-
target | A destination for the periodic message. |
pause | Pause for message delaying. |
args | Message constructor parameters. |
Definition at line 637 of file pub.hpp.
template<typename Message , typename Target , typename... Args>
SO_5_NODISCARD timer_id_t so_5::extra::revocable_timer::send_periodic |
( |
Target && |
target, |
|
|
std::chrono::steady_clock::duration |
pause, |
|
|
std::chrono::steady_clock::duration |
period, |
|
|
Args &&... |
args |
|
) |
| |
A utility function for creating and delivering a periodic message to the specified destination.
Agent, mbox or mchain can be used as target.
- Note
- Message chains with overload control must be used for periodic messages with additional care because exceptions can't be thrown during dispatching messages from timer.
Usage example 1:
class my_agent : public so_5::agent_t {
timer_ns::timer_id_t timer_;
...
void so_evt_start() override {
...
timer_ = timer_ns::send_periodic<do_some_task>(*this, 1s, 1s, ...);
...
}
...
};
Usage example 2:
so_5::wrapped_env_t sobj;
so_5::mbox_t worker_mbox = sobj.environment().introduce_coop(
[&](so_5::coop_t & coop) {
auto worker = coop.make_agent<worker_agent>(...);
return worker->so_direct_mbox();
});
auto timer_id = so_5::extra::revocable_timer::send_periodic<tell_status>(
worker_mbox(),
1s, 1s,
... );
...
timer_id.release();
- Note
- The return value of that function must be stored somewhere. Otherwise the periodic timer will be cancelled automatically just right after send_periodic returns.
- Attention
- Values of pause and period should be non-negative.
- Template Parameters
-
Message | type of message or signal to be sent. |
Target | can be so_5::agent_t, so_5::mbox_t or so_5::mchain_t. |
Args | list of arguments for Message's constructor. |
- Since
- v.1.2.0
- Parameters
-
target | A destination for the periodic message. |
pause | Pause for message delaying. |
period | Period of message repetitions. |
args | Message constructor parameters. |
Definition at line 378 of file pub.hpp.
template<typename Message , typename Target >
SO_5_NODISCARD timer_id_t so_5::extra::revocable_timer::send_periodic |
( |
Target && |
target, |
|
|
std::chrono::steady_clock::duration |
pause, |
|
|
std::chrono::steady_clock::duration |
period, |
|
|
::so_5::mhood_t< Message > |
mhood |
|
) |
| |
A helper function for redirection of a message/signal as a periodic message/signal.
This function can be used if target is a reference to agent or if target is a mchain
Example usage:
class my_agent : public so_5::agent_t {
...
so_5::mchain_t target_mchain_;
timer_ns::timer_id_t periodic_msg_id_;
...
void on_some_msg(mhood_t<some_msg> cmd) {
if( ... )
}
- Note
- The return value of that function must be stored somewhere. Otherwise the periodic timer will be cancelled automatically just right after send_periodic returns.
- Attention
- Values of pause and period should be non-negative.
- Since
- v.1.2.0
- Parameters
-
target | A target for periodic message/signal. It can be a reference to a target agent or a mchain_t. |
pause | Pause for the first occurence of the message/signal. |
period | Period of message repetitions. |
mhood | Existing message hood for message/signal to be sent. |
Definition at line 556 of file pub.hpp.