SObjectizer
5.7
|
Version 5.2.3 introduces some features for informing agents about cooperation related events.
Very important change in v.5.2.3 is the introduction of so_5::rt::coop_dereg_reason_t structure and so_5::rt::dereg_reason namespace. The so_5::rt::coop_dereg_reason_t describes the reason of cooperation deregistration. For example: normal deregistration due to application logic (value so_5::rt::dereg_reason::normal) or deregistration as a reaction to unhandled exception (value so_5::rt::dereg_reason::unhandled_exception) or because the parent cooperation is being deregistered (value so_5::rt::dereg_reason::parent_deregistration).
At the moment coop_dereg_reason_t contains only one value – integer deregistration reason code which is accessible via so_5::rt::coop_dereg_reason_t::reason() method. But in the future SObjectizer versions the content of coop_dereg_reason_t could be expanded.
The format of so_5::rt::so_environment_t::deregister_coop() is changed. Now this method requires not only the cooperation name but also an integer deregistration reason code. So the code which uses deregister_coop() should be adapted when switching to SObjectizer v.5.2.3.
The deregistration reason codes are divided into two parts: values below so_5::rt::dereg_reason::user_defined_reason is reserved for SObjectizer. The user could use these values (like mentioned above normal, unhandled_exception and parent_deregistration), but must not change its meaning.
Values from so_5::rt::dereg_reason::user_defined_reason and above could be used for user purposes. So it is possible to define and use domain specific reason codes, like:
The format of so_5::rt::coop_listener_t::on_deregistered() is changed: now it receives not only name of deregistered cooperation but also the cooperation deregistration reason:
It is incompatible with previous version and appropriate changes must be applied to cooperation listeners.
A new thing is introduced in v.5.2.3: this is cooperation registration notificators. Notificator is a functional object with prototype:
The precise type of registration notificator is defined in so_5::rt::coop_reg_notificator_t typedef.
Notificators should be bound to cooperation object before cooperation registration:
There is no limit for cooperation reg_notificator count. All of them will be called by SObjectizer Environment inside so_5::rt::so_environment_t::register_coop() method right after all registration specific actions will be complete.
Cooperation deregistration noitificators are introduced together with registration notificators. They are also functional objects but with prototype:
The precise type of registration notificator is defined in so_5::rt::coop_reg_notificator_t typedef.
Notificators should be bound to cooperation object before cooperation registration:
There is no limit for cooperation dereg_notificator count. All of them will be called by SObjectizer Environment method right after final cooperation deregistration actions. Cooperation object will be destroyed before invoking deregistration notificators.
SObjectizer provides standard implementation for reg_
and dereg_notificators
. They just send so_5::rt::msg_coop_registered and so_5::rt::msg_coop_deregistered to the mbox specified. Standard reg_notificator
is created by so_5::rt::make_coop_reg_notificator() function. And standard dereg_notificator is created by so_5::rt::make_coop_dereg_notificator() function. They could be used for controlling lifetime of child cooperation, for example: