|
| | environment_t (environment_params_t &&so_environment_params) |
| |
| virtual | ~environment_t () |
| |
| | environment_t (const environment_t &)=delete |
| |
| environment_t & | operator= (const environment_t &)=delete |
| |
| void | call_exception_logger (const std::exception &event_exception, const std::string &coop_name) |
| | Call event exception logger for logging an exception. More...
|
| |
| exception_reaction_t | exception_reaction () const |
| | An exception reaction for the whole SO Environment. More...
|
| |
| error_logger_t & | error_logger () const |
| | Get the error_logger object. More...
|
| |
| template<class Agent , typename... Args> |
| std::unique_ptr< Agent > | make_agent (Args &&... args) |
| | Helper method for simplification of agents creation. More...
|
| |
| stats::controller_t & | stats_controller () |
| | Access to controller of run-time monitoring. More...
|
| |
| stats::repository_t & | stats_repository () |
| | Access to repository of data sources for run-time monitoring. More...
|
| |
| template<typename... Args> |
| void | introduce_coop (Args &&... args) |
| | Helper method for simplification of cooperation creation and registration. More...
|
| |
| work_thread_activity_tracking_t | work_thread_activity_tracking () const |
| | Get activity tracking flag for the whole SObjectizer Environment. More...
|
| |
| disp_binder_unique_ptr_t | so_make_default_disp_binder () |
| | Get binding to the default dispatcher. More...
|
| |
| bool | autoshutdown_disabled () const |
| | Get autoshutdown_disabled flag. More...
|
| |
| so_5::timer_id_t | schedule_timer (const std::type_index &type_wrapper, const message_ref_t &msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period) |
| | Schedule timer event. More...
|
| |
| void | single_timer (const std::type_index &type_wrapper, const message_ref_t &msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause) |
| | Schedule a single shot timer event. More...
|
| |
| template<typename Lambda > |
| mbox_t | make_custom_mbox (Lambda &&lambda) |
| | Create a custom mbox. More...
|
| |
|
| mbox_t | create_mbox () |
| | Create an anonymous mbox with the default mutex. More...
|
| |
| mbox_t | create_mbox (nonempty_name_t mbox_name) |
| | Create named mbox. More...
|
| |
| mbox_t | create_local_mbox () |
| |
| mbox_t | create_local_mbox (nonempty_name_t mbox_name) |
| |
|
| mchain_t | create_mchain (const mchain_params_t ¶ms) |
| | Create message chain. More...
|
| |
|
| dispatcher_t & | query_default_dispatcher () |
| | Access to the default dispatcher. More...
|
| |
| dispatcher_ref_t | query_named_dispatcher (const std::string &disp_name) |
| | Get named dispatcher. More...
|
| |
| void | install_exception_logger (event_exception_logger_unique_ptr_t logger) |
| | Set up an exception logger. More...
|
| |
| dispatcher_ref_t | add_dispatcher_if_not_exists (const std::string &disp_name, std::function< dispatcher_unique_ptr_t() > disp_factory) |
| | Add named dispatcher if it is not exists. More...
|
| |
|
| coop_unique_ptr_t | create_coop (nonempty_name_t name) |
| | Create a cooperation. More...
|
| |
| coop_unique_ptr_t | create_coop (autoname_indicator_t indicator()) |
| | Create a cooperation with automatically generated name. More...
|
| |
| coop_unique_ptr_t | create_coop (nonempty_name_t name, disp_binder_unique_ptr_t disp_binder) |
| | Create a cooperation. More...
|
| |
| coop_unique_ptr_t | create_coop (autoname_indicator_t indicator(), disp_binder_unique_ptr_t disp_binder) |
| | Create a cooperation with automatically generated name. More...
|
| |
| void | register_coop (coop_unique_ptr_t agent_coop) |
| | Register a cooperation. More...
|
| |
| template<class A > |
| void | register_agent_as_coop (nonempty_name_t coop_name, std::unique_ptr< A > agent) |
| | Register single agent as a cooperation. More...
|
| |
| template<class A > |
| void | register_agent_as_coop (autoname_indicator_t indicator(), std::unique_ptr< A > agent) |
| | Register single agent as a cooperation with automatically generated name. More...
|
| |
| void | register_agent_as_coop (nonempty_name_t coop_name, agent_t *agent) |
| | Register single agent as a cooperation. More...
|
| |
| void | register_agent_as_coop (autoname_indicator_t indicator(), agent_t *agent) |
| | Register single agent as a cooperation with automatically generated name. More...
|
| |
| template<class A > |
| void | register_agent_as_coop (nonempty_name_t coop_name, std::unique_ptr< A > agent, disp_binder_unique_ptr_t disp_binder) |
| | Register single agent as a cooperation with specified dispatcher binder. More...
|
| |
| template<class A > |
| void | register_agent_as_coop (autoname_indicator_t indicator(), std::unique_ptr< A > agent, disp_binder_unique_ptr_t disp_binder) |
| | Register single agent as a cooperation with specified dispatcher binder and automatically generated name. More...
|
| |
| void | register_agent_as_coop (nonempty_name_t coop_name, agent_t *agent, disp_binder_unique_ptr_t disp_binder) |
| | Register single agent as a cooperation with specified dispatcher binder. More...
|
| |
| void | register_agent_as_coop (autoname_indicator_t indicator(), agent_t *agent, disp_binder_unique_ptr_t disp_binder) |
| | Register single agent as a cooperation with specified dispatcher binder and automatically generated name. More...
|
| |
| void | deregister_coop (nonempty_name_t name, int reason) |
| | Deregister the cooperation. More...
|
| |
|
| template<class Message > |
| so_5::timer_id_t | schedule_timer (std::type_index subscription_type, std::unique_ptr< Message > msg, message_mutability_t mutability, const mbox_t &mbox, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period) |
| | Schedule timer event. More...
|
| |
| template<class Message > |
| so_5::timer_id_t | schedule_timer (std::unique_ptr< Message > msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period) |
| | Schedule timer event. More...
|
| |
| template<class Message > |
| so_5::timer_id_t | schedule_timer (std::unique_ptr< Message > msg, const mbox_t &mbox, unsigned int delay_msec, unsigned int period_msec) |
| | Schedule timer event. More...
|
| |
| template<class Message > |
| so_5::timer_id_t | schedule_timer (const mbox_t &mbox, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period) |
| | Schedule a timer event for a signal. More...
|
| |
| template<class Message > |
| so_5::timer_id_t | schedule_timer (const mbox_t &mbox, unsigned int delay_msec, unsigned int period_msec) |
| | Schedule a timer event for a signal. More...
|
| |
| template<class Message > |
| void | single_timer (std::unique_ptr< Message > msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause) |
| | Schedule a single shot timer event. More...
|
| |
| template<class Message > |
| void | single_timer (std::type_index subscription_type, std::unique_ptr< Message > msg, message_mutability_t mutability, const mbox_t &mbox, std::chrono::steady_clock::duration pause) |
| | Schedule a single shot timer event. More...
|
| |
| template<class Message > |
| void | single_timer (std::unique_ptr< Message > msg, const mbox_t &mbox, unsigned int delay_msec) |
| | Schedule a single shot timer event. More...
|
| |
| template<class Message > |
| void | single_timer (const mbox_t &mbox, std::chrono::steady_clock::duration pause) |
| | Schedule a single shot timer event for a signal. More...
|
| |
| template<class Message > |
| void | single_timer (std::type_index subscription_type, const mbox_t &mbox, std::chrono::steady_clock::duration pause) |
| | Schedule a single shot timer event for a signal. More...
|
| |
| template<class Message > |
| void | single_timer (const mbox_t &mbox, unsigned int delay_msec) |
| | Schedule a single shot timer event for a signal. More...
|
| |
|
| template<class SO_Layer > |
| SO_Layer * | query_layer_noexcept () const |
| |
| template<class SO_Layer > |
| SO_Layer * | query_layer () const |
| | Get access to the layer with exception if layer is not found. More...
|
| |
| template<class SO_Layer > |
| void | add_extra_layer (std::unique_ptr< SO_Layer > layer_ptr) |
| | Add an additional layer. More...
|
| |
| template<class SO_Layer > |
| void | add_extra_layer (SO_Layer *layer_raw_ptr) |
| | Add an additional layer via raw pointer. More...
|
| |
|
| void | run () |
| | Run the SObjectizer Run-Time. More...
|
| |
| virtual void | init ()=0 |
| | Initialization hook. More...
|
| |
| void | stop () |
| | Send a shutdown signal to the Run-Time. More...
|
| |
|
| stop_guard_t::setup_result_t | setup_stop_guard (stop_guard_shptr_t guard, stop_guard_t::what_if_stop_in_progress_t reaction_on_stop_in_progress=stop_guard_t::what_if_stop_in_progress_t::throw_exception) |
| | Set up a new stop_guard. More...
|
| |
| void | remove_stop_guard (stop_guard_shptr_t guard) |
| | Remove stop_guard and complete the stop operation if necessary. More...
|
| |
|
| void | change_message_delivery_tracer_filter (so_5::msg_tracing::filter_shptr_t filter) |
| | Change the current msg_tracing's filter to a new one. More...
|
| |
SObjectizer Environment.
Basic information
The SObjectizer Environment provides a basic infrastructure for the SObjectizer Run-Time execution.
The main method of starting SObjectizer Environment creates a class derived from the environment_t and reimplementing the environment_t::init() method. This method should be used to define starting actions of application. For example first application cooperations can be registered here and starting messages can be sent to them.
The SObjectizer Environment calls the environment_t::init() when the SObjectizer Run-Time is successfully started. If something happened during the Run-Time startup then the method init() will not be called.
The SObjectizer Run-Time is started by the environment_t::run(). This method blocks the caller thread until SObjectizer completely finished its work.
The SObjectizer Run-Time is finished by the environment_t::stop(). This method doesn't block the caller thread. Instead it sends a special shutdown signal to the Run-Time. The SObjectizer Run-Time then informs agents about this and waits finish of agents work. The SObjectizer Run-Time finishes if all agents are stopped and all cooperations are deregistered.
Methods of the SObjectizer Environment can be splitted into the following groups:
- working with mboxes;
- working with dispatchers, exception loggers and handlers;
- working with cooperations;
- working with delayed and periodic messages;
- working with additional layers;
- initializing/running/stopping/waiting of the Run-Time.
Methods for working with mboxes.
SObjectizer Environment allows creation of named and anonymous mboxes. Syncronization objects for these mboxes can be obtained from common pools or assigned by a user during mbox creation.
Mboxes are created by environment_t::create_mbox() methods. All these methods return the mbox_t which is a smart reference to the mbox.
An anonymous mbox is automatically destroyed when the last reference to it is destroyed. So, to save the anonymous mbox, the mbox_ref from the create_mbox() should be stored somewhere.
Named mbox must be destroyed manually by calling the environment_t::destroy_mbox() method. But physically the deletion of the named mbox postponed to the deletion of last reference to it. So if there is some reference to the named mbox it instance will live with this reference. But mbox itself will be removed from SObjectizer Environment lists.
Methods for working with cooperations.
Cooperations can be created by environment_t::create_coop() methods.
The method environment_t::register_coop() should be used for the cooperation registration.
Method environment_t::deregister_coop() should be used for the cooperation deregistration.
Methods for
sending delayed and periodic messages.
Receiving of delayed and/or periodic messages are named as timer events.
The timer event can be created and destroyed. If the timer event for a delayed message is destroyed before message timeout is expired then message delivery will be canceled. For periodic messages destroying of the timer event means that message delivery will be stopped.
Timer events can be created by environment_t::schedule_timer() methods. The one version of the schedule_timer() is intended for messages with an actual data. The second one – for the signals without the message data.
Methods schedule_timer() return a special reference for the timer event. Timer event destroyed when this reference destroyed. So it is necessary to store this reference somewhere. Also the timer event can be destroyed by the so_5::timer_thread::timer_id_ref_t::release() method.
A special method environment_t::single_timer() can be used in case when a single shot timer event is necessary. With using this method there is no need to store reference for the scheduled single shot timer event.
- Examples:
- so_5/adv_thread_pool_fifo/main.cpp, so_5/blinking_led/main.cpp, so_5/chameneos_prealloc_msgs/main.cpp, so_5/chameneos_simple/main.cpp, so_5/chstate/main.cpp, so_5/chstate_msg_tracing/main.cpp, so_5/collector_many_performers/main.cpp, so_5/collector_performer_pair/main.cpp, so_5/coop_listener/main.cpp, so_5/coop_notification/main.cpp, so_5/coop_user_resources/main.cpp, so_5/custom_error_logger/main.cpp, so_5/deadletter_handler/main.cpp, so_5/delivery_filters/main.cpp, so_5/dining_philosophers/main.cpp, so_5/dining_philosophers_2/main.cpp, so_5/disp/main.cpp, so_5/exception_logger/main.cpp, so_5/exception_reaction/main.cpp, so_5/hardwork_imit/main.cpp, so_5/hello_all/main.cpp, so_5/hello_delay/main.cpp, so_5/hello_evt_handler/main.cpp, so_5/hello_evt_lambda/main.cpp, so_5/hello_periodic/main.cpp, so_5/hello_world/main.cpp, so_5/hello_world_adhoc/main.cpp, so_5/hello_world_simple_not_mtsafe/main.cpp, so_5/intercom_statechart/main.cpp, so_5/machine_control/main.cpp, so_5/make_pipeline/main.cpp, so_5/many_timers/main.cpp, so_5/modify_resend_as_immutable/main.cpp, so_5/mutable_msg_agents/main.cpp, so_5/news_board/main.cpp, so_5/nohandler_msg_tracing/main.cpp, so_5/parent_coop/main.cpp, so_5/ping_pong/main.cpp, so_5/ping_pong_minimal/main.cpp, so_5/ping_pong_with_owner/main.cpp, so_5/prio_work_stealing/main.cpp, so_5/private_dispatcher_for_children/main.cpp, so_5/private_dispatcher_hello/main.cpp, so_5/private_dispatcher_restarts/main.cpp, so_5/producer_consumer_mchain/main.cpp, so_5/queue_size_stats/main.cpp, so_5/redirect_and_transform/main.cpp, so_5/selective_msg_tracing/main.cpp, so_5/simple_message_deadline/main.cpp, so_5/state_deep_history/main.cpp, so_5/stop_guard/main.cpp, so_5/subscriptions/main.cpp, so_5/svc/exceptions/main.cpp, so_5/svc/hello/main.cpp, so_5/svc/parallel_sum/main.cpp, so_5/two_handlers/main.cpp, and so_5/work_generation/main.cpp.