Provides a variety of scheduler classes to coordinate coroutines.
Schedulers are responsible for the main program loop, cycling through each registered coroutine in turn. They also send post office messages into the registered coroutines and post emitted messages back to the post office.
Bases: object
The standard scheduler class to run coroutines.
This is a simple and reasonably efficient implementation of IScheduler. Unless you have a special need, this is this probably scheduler you want to use.
Parameters: | post_office (m4us.core.interfaces.IPostOffice) -- The post office object to use for message routing. |
---|---|
Raises exceptions.TypeError: | |
If the given post office does not provide or cannot be adapted to IPostOffice. | |
Implements : | m4us.core.interfaces.IScheduler |
Provides : | m4us.core.interfaces.ISchedulerFactory |
See also
The IPostOffice interface for details on post offices.
Cycle once through the main loop, running all eligible coroutines.
Warning
The current implementation of this method can handle a shrinking run queue due to coroutines shutting down, but it has not yet been designed to handle the dynamic adding or removing of coroutines within a the cycle execution. It's behaviour in those situations is currently undefined.
See also
The IScheduler interface for details about this method.
See also
The step() method for details how the coroutines are run.
Register one or more coroutines with the scheduler.
See also
The IScheduler interface for details about this method.
Start the scheduler, running all registered coroutines.
Warning
If cycles is not specified and any of the coroutines do not cascade IShutdown messages or shutdown properly, then this method will likely loop forever.
See also
The IScheduler interface for details about this method.
See also
The cycle() method for details how the coroutines are run.
Run one coroutine.
Note
Coroutines are run in a round-robin style, in the order that they have been added. Coroutines should not, however, rely on this implementation detail.
See also
The IScheduler interface for details about this method.
Unregister one or more coroutines from the scheduler.
See also
The IScheduler interface for details about this method.