Wiki

Clone wiki

pymoult / managers

#Managers

Pymoult provides two types of managers : a non threaded manager called Manager and a Threaded Manager called ThreadedManager. Both of them ar compatible with any kind of update class.

Both manager hold a list of pending updates to which updates can be append using the add_update method.

When instanciating a manager, several threads can be given as arguments. These threads are "controlled" by the manager : they will be suspended when applying an update.

BaseManager

This is the base class of all managers. It is not meant to be used.

Manager

This manager is to be executed by threads of the application as it does not runs in a specific thread. Calling apply_nexy_update will make it apply the next pending update if its alterability and its requirements are met. Else, the method will return. If an update is already being applyed, this method will check its ending conditions. If they are met, the update will be considered finished and the name of that update will be remembered in the application. If they are not, the method returns

ThreadedManager

This manager runs in its own thread,meaning that it must be started by calling its start method. The manager will check if new updates are to be applied by itself and run them one by one. Checking alterability, requirements and ending conditions each time. As in the non threaded manager, finished update are remembered in the application.

This manager provides a wait method that can be called to wait for the next update applied by the manager to be over.

generatePreconfiguredManager

This function generates a Manager class preconfigured for using a single kind of update for all its life. It takes as argument a manager class to base itself upon (i.e. it will behave either as a Manager or as a ThreadedManager), an Update class and a dictionnary of attributes.

The generated class will behave as the manager class given as argument and will apply only the tyep of update that was given to it. Instead of taking update object as arguments, its add_update method takes a bundle. That bundle is a dictionnary of arguments that will be used to instanciate the Update class it follows. That instance will be applied by the manager like other types of manager would.

Updated