The strategy remover a component of the Dynamic
Configurator and it is responsible for unloading strategies from memory
once they have reached a stable state. It has been implemented as a thread
that it is spawned at the open method of the Dynamic Configurator, and
it blocks on a semaphore until it gets requests for unloading.
1. Interface definition
The strategy remover inherits from ACE_Task, which is the base class
for implementing threads in ACE.
2. Description
Besides the standard methods inherited from the parent, Strategy_Remover
defines a static method called remove which receives two parameters,
a handler to the strategy and a thread id. The thread id is used for synchoronization
purposes. The strategy won't be removed until the thread referenced by
the id passed as a parameter has finished its execution. This means that
the one that has to call this method is always the last thread that is
still using the strategy. Otherwise the strategy will be removed when there
are still threads executing and using that code.
3. Obtaining and using the Strategy Remover
4. Implications
With this new framework for deleting strategies, there is at least one implication that must be considered. In the case of deleting a strategy, it may happen that the strategy cannot be removed immediately. In such case, the service will still be contained in the ACE_Repository. That means that a user could send a request to hook that strategy, which would cause non desired effects once the service was finally unloaded by the strategy remover. To avoid this problem, the hook method will query the Strategy_Factory, wheter or not the strategy can be hooked. The strategy factory will check the strategy it provides in order to see if it can be unloaded. The way the strategy factory checks the status of the strategy is left to the programmer.