SObjectizer  5.7
so-5.5.18: Global lock_factories

Message queues in SObjectizer dispatchers use synchronization objects to protect the contents of the queue when working with it from several threads. Synchronization objects are created with the help of special factories (so-called lock_factory). The developer can point which particular lock_factory should be used when creating specific dispatcher.

This feature is available since 5.5.10 and 5.5.11 versions. Also since then two types of lock_factories were implemented:

By default combined_lock_factory is used. This can be changed in message queue properties to simple_lock_factory if needed.

Before version 5.5.18 it was possible to replace combined_lock_factory with simple_lock_factory only for one separate dispatcher. That is when creating dispatcher in its queue_traits simple_lock_factory is selected. Which was uncomfortable if the application created more than one dispatcher (or even more than ten): one had to remember to configure the queue_traits for each of them.

Even worse if the application uses ready-made library of agents inside of which its own dispatcher instances are created. Likely this library doesn't provide an opportunity to configure queue_traits for its own dispatchers but uses the default parameters of queue_traits, i.e. combined_lock_factory will be used.

In version 5.5.18 this defect was fixed by adding the feature to set the default lock_factories for the whole SObjectizer Environment. That is if all application's dispatchers in their queues should use only simple_lock_factory by default this can be configured via environment_params_t since version 5.5.18. For example:

... // Some initial actions.
},
[]( so_5::environment_params_t & params ) {
// Use simple_lock_factory for event queues by default.
params.queue_locks_defaults_manager(
...
} );

After that for dispatcher creation the following scenario is used:

  1. If the developer in queue_traits set the specific lock_factory for dispatcher then when creating queues of this dispatcher the specific lock_factory will be used. Global parameters of SObjectizer Environment are ignored.
  2. Ohterwise when creating queues of this dispatcher the lock_factory will be used from SObjectizer Environment parameters. In the example above it is simple_lock_factory.
    Herewith the application doesn't care where particular the dispatcher is created: in the application code or in the third-party library. If the lock_factory is not set explicitly when creating dispatcher then the lock_factory will be used by default.

If the developer didn't set queue_locks_defaults_manager explicitly during SObjectizer Environment start then combined_lock_factory will be used by default. So the default behavior of dispatchers and queues in SObjectizer in version 5.5.18 is not changed.