#include <iostream>
#include <string>
struct two_ints
{
int a, b;
};
struct delayed_two_ints
{
int a, b;
};
void demo()
{
std::chrono::minutes{5},
3u,
std::thread worker{ [&]{
ch, std::chrono::milliseconds{150}, 1, 2 );
ch, std::chrono::milliseconds{20}, std::chrono::milliseconds{150} );
} };
[]( const std::string & v ) { std::cout << "str: " << v << std::endl; },
[]( int v ) { std::cout << "int: " << v << std::endl; },
std::cout << "two_ints: " << v->a << ", " << v->b << std::endl;
},
std::cout << "delayed_two_ints: " << v->a << ", " << v->b << std::endl;
},
std::cout << "just signal" << std::endl;
},
std::cout << "periodic signal" << std::endl;
} );
worker.join();
}
int main()
{
try
{
demo();
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
}
return 0;
}
A helper header file for including all public SObjectizer stuff.
A message wrapped to be used as type of argument for event handlers.
A base class for agent signals.
An indentificator for the timer.
@ abort_app
Application must be aborted.
@ preallocated
Storage must be preallocated once and doesn't change after that.
mchain_receive_params_t< mchain_props::msg_count_status_t::undefined > from(mchain_t chain)
A helper function for simplification of creation of mchain_receive_params instance.
mchain_t create_mchain(environment_t &env)
Create size-unlimited chain.
void close_drop_content(Exceptions_Control exceptions_control, const mchain_t &ch) noexcept(noexcept(details::should_terminate_if_throws_t< Exceptions_Control >::value))
Helper function for closing a message chain with dropping all its content.
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.
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
void 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.
constexpr exceptions_enabled_t exceptions_enabled
Value that indicates that exceptions are enabled.
mchain_receive_result_t receive(const mchain_receive_params_t< Msg_Count_Status > ¶ms, Handlers &&... handlers)
Advanced version of receive from mchain.