SObjectizer 5.8
|
Parent-child cooperation relationship from SObjectizer-4 is implemented in version 5.2.3. It allows to specify the parent cooperation for new cooperation before new cooperation registration. Then if the parent cooperation deregistered all its children cooperations will be deregistered automatically. If some child cooperation has its own children cooperations they will be deregistered as well.
The parent-child relation serves for two main purposes:
To specify parent cooperation new method so_5::rt::agent_coop_t::set_parent_coop_name() was introduced. It must be applied with the name of already registered cooperation in order to set parent-child relationship. The usage of that method looks like:
Name of parent cooperation is checked inside the so_5::rt::so_environment_t::register_coop() method. The cooperation with specified name must be registered at that moment and must not be under deregistration process. If cooperation name is unknown or parent cooperation is being deregistered then an error is raised.
When name of a parent cooperation is passed to so_5::rt::so_environment_t::deregister_coop() then SObjectizer makes a full list of all children cooperations (e.g. direct children cooperations, children of children and so on). And then initiates deregistration for all of them at once. It means that all cooperations will receive deregistration signal at the same time. But because cooperation deregistration could take some time some of cooperations could finish their deregistration process earlier and some later. Because of that agents of the parent cooperation could finish their work before agents from children cooperations.
But the destruction of cooperation will be done in particular order. Cooperations without any children will be deregistered at first turn. Then the parents of already deregistered cooperations will be deregistered. Then parents of those parents and so on. The root cooperation which name was specified in so_5::rt::so_environment_t::deregister_coop() will be destroyed the last.