Mercury Currency Engine
|
an interface for implementing lifecycle control operations More...
#include <scheduler.hpp>
Classes | |
struct | implementation |
virtual interface for implementors of lifecycle More... | |
Public Types | |
enum | state { ready , running , suspended , halted } |
an enumeration which represents the lifecycle object's current state More... | |
Public Member Functions | |
lifecycle (implementation *self) | |
lifecycle (implementation *self, implementation *root) | |
state | get_state () |
return the state of the lifecycle | |
bool | suspend () |
temporarily suspend operations More... | |
void | resume () |
resume any current or future call to run() after an suspend() | |
void | halt () |
halt and join lifecycle execution More... | |
an interface for implementing lifecycle control operations
|
inline |
Any implementation of lifecycle should pass its this
pointer to its lifecycle constructor.
|
inline |
Call public methods with the root lifecycle implementation's methods.
Lifecycle objects can be structured as a tree, where lifecycle objects own other lifecycle objects: root - child1 - child1-child1
child2 - child2-child1
etc
If each child is given the root's pointer, then root's _impl()
methods will be called when the child's public methods are called. This allows synchronized lifecycle operations no matter where in the tree lifecycle
public methods are called from.
In short: if suspend()
/resume()
/halt()
/etc are called on a child object, and the child object was constructed with a root lifecycle pointer, the root's suspend_impl()
/resume_impl()
/halt_impl()
methods will actually* be called.
All parent lifecycle
_impl()
methods should only call child _impl()
methods when interacting with child lifecycle
objects. IE, _impl()
methods should not call public lifecycle
methods.
|
inline |
halt and join lifecycle execution
As a general rule, mce::lifecycle
implementations are intended to run indefinitely and halt() should only be called on process shutdown. Failure to do so can cause strange program errors where code which is expected to run does not.
|
inline |
temporarily suspend operations
false
if lifecycle is halted, else true