Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What's new in SObjectizer 5.5.9

261 views

Published on

Short overview of new features and improvements in SObjectizer-5.5.9

Published in: Software
  • Be the first to comment

  • Be the first to like this

What's new in SObjectizer 5.5.9

  1. 1. What’s new in SObjectizer-5.5.9 SObjectizer Team, Oct 2015 A Short Overview
  2. 2. There are several new features in SObjectizer v.5.5.9. Three of them could be seen as important additions to SObjectizer’s capabilities: ● an ability to use an arbitrary user type as a message type; ● new class wrapped_env_t; ● an ability to trace message delivery process. There are also several improvements for existing features. This presentation briefly describes all of them. SObjectizer Team, Oct 2015
  3. 3. Arbitrary user type as message type SObjectizer Team, Oct 2015
  4. 4. Until v.5.5.9 all messages must have been derived from so_5::rt:: message_t. Even if an agent had to send just one int-value to another agent that int-value had to be a member of dedicated C++ class/struct: // Definition of message-related stuff. enum class engine_action { turn_on, speed_up, slow_down, turn_off }; struct msg_engine_action : public so_5::rt::message_t { engine_action m_action; msg_engine_action( engine_action action ) : m_action{ action } {} }; // Message sending... so_5::send_to_agent< msg_engine_action >( engine_agent, engine_action::turn_on ); // Message processing... void engine_agent::evt_engine_action( const msg_engine_action & msg ) { switch( msg.m_action ) {...} } SObjectizer Team, Oct 2015
  5. 5. Since v.5.5.9 it is possible to use arbitrary user-defined types as types of messages. Inheritance from so_5::rt::message_t is not mandatory anymore: // Definition of message-related stuff. enum class engine_action { turn_on, speed_up, slow_down, turn_off }; // Message sending... so_5::send_to_agent< engine_action >( engine_agent, engine_action::turn_on ); // Message processing... void engine_agent::evt_engine_action( const engine_action & action ) { switch( action ) {...} } SObjectizer Team, Oct 2015
  6. 6. The only requirement for such types is very simple: a type T can be used as type of message if T is MoveConstructible. It is because SObjectizer creates an instance of an envelope of special type so_5::rt::user_type_message_t<T> and temporary object of type T is used to initialize payload field inside that envelope: template< typename T > struct user_type_message_t : public message_t { const T m_payload; template< typename... ARGS > user_type_message_t( ARGS &&... args ) : m_payload( T{ std::forward< ARGS >( args )... } ) {} }; SObjectizer Team, Oct 2015
  7. 7. The messages of arbitrary user types are first-class citizens in SObjectizer v.5.5.9. They can be used in asynchronous and synchronous interactions. Delivery filters and message limits can be specified for user-type messages. But signals must still be present as structs/classes derived from so_5::rt::signal_t. SObjectizer Team, Oct 2015
  8. 8. More information about user-type messages can be found in the corresponding Wiki-section. SObjectizer Team, Oct 2015
  9. 9. Class wrapped_env_t SObjectizer Team, Oct 2015
  10. 10. A traditional way of launching SObjectizer Environment via so_5:: launch() is simple and useful. But only if an application is built on top of SObjectizer only. Usage of so_5::launch() could be not very convenient in other cases. For example if an application uses some form of message loop for handling GUI events. An attempt to use so_5::launch() in such cases could look like... SObjectizer Team, Oct 2015
  11. 11. A possible way of using so_5::launch() with classical message loop: int main() { so_5::rt::environment_t * env_ptr = nullptr; // To be set inside launch(); so_5::launch( [&]( so_5::rt::environment_t & env ) { env_ptr = &env; ... // Some SO Environment initialization code. } ); ... // Some application-specific initialization code. while(!GetMessage(...)) ProcessMessage(...); env_ptr->stop(); // Stopping SO Environment. // NOTE: there is no way to wait for a complete finish of SO Environment work! ... // Some application-specific deinitialization code. } SObjectizer Team, Oct 2015
  12. 12. It is easy to see that this scenario is not simple and straightforward. It is just an opposite: fragile and error prone. So to simplify usage of SObjectizer with other frameworks and events/messages handling loops in one application a new class has been introduced in v.5.5.9: so_5::wrapped_env_t. SObjectizer Team, Oct 2015
  13. 13. A possible way of using so_5::wrapped_env_t with classical message loop: int main() { so_5::wrapped_env_t env; // Empty SO Environment will be started here. env.environment().introduce_coop( []( so_5::rt::coop_t & coop ) { ... // Some SO Environment initialization code. } ); ... // Some application-specific initialization code. while(!GetMessage(...)) ProcessMessage(...); env.stop_then_join(); // Stopping SO Environment and wait for complete finish. ... // Some application-specific deinitialization code. } SObjectizer Team, Oct 2015
  14. 14. More information about so_5::wrapped_env_t and details of its work can be found in the corresponding Wiki-section. SObjectizer Team, Oct 2015
  15. 15. Message Delivery Tracing SObjectizer Team, Oct 2015
  16. 16. A new mechanism for simplification of debugging SObjectizer’s application has been added in v.5.5.9: message delivery tracing. This mechanism can be activated on the start of SObjectizer Environment. After activation of message delivery tracing a full log of messages delivery will be formed. This log will contain traces of all important stages of message processing: pushing of a message to event queues of subscribers, rejection of a message by a delivery filter, searching of an event handler for a message, overlimit reactions... SObjectizer Team, Oct 2015
  17. 17. A new example has been added to the SObjectizer distributive: chstate_with_tracing. This example shows how message traces could look (under GCC v.5.2.0): [tid=3][mbox_id=4] deliver_message.push_to_queue [msg_type=N17a_state_swither_t16greeting_messageE][envelope_ptr=0x5565a0] ↳ [payload_ptr=0x5565b0][overlimit_deep=1][agent_ptr=0x556320] [tid=2][agent_ptr=0x556320] demand_handler_on_message.find_handler [mbox_id=4] ↳ [msg_type=N17a_state_swither_t16greeting_messageE][envelope_ptr=0x5565a0][payload_ptr=0x5565b0] ↳ [state=<DEFAULT>][evt_handler=0x55ab38] *** 0) greeting: Hello, World!, ptr: 0x5565b0 [tid=3][mbox_id=4] deliver_message.push_to_queue [msg_type=N17a_state_swither_t19change_state_signalE][signal] ↳ [overlimit_deep=1][agent_ptr=0x556320] [tid=2][agent_ptr=0x556320] demand_handler_on_message.find_handler [mbox_id=4] ↳ [msg_type=N17a_state_swither_t19change_state_signalE][signal][state=<DEFAULT>][evt_handler=0x55aaf8] [tid=3][mbox_id=4] deliver_message.push_to_queue [msg_type=N17a_state_swither_t16greeting_messageE][envelope_ptr=0x5565a0] ↳ [payload_ptr=0x5565b0][overlimit_deep=1][agent_ptr=0x556320] [tid=2][agent_ptr=0x556320] demand_handler_on_message.find_handler [mbox_id=4] ↳ [msg_type=N17a_state_swither_t16greeting_messageE][envelope_ptr=0x5565a0] ↳ [payload_ptr=0x5565b0][state=state_1][evt_handler=NONE] SObjectizer Team, Oct 2015

×