Source code for ducky.interfaces

[docs]class IMachineWorker(object): """ Base class for objects that provide pluggable service to others. """
[docs] def boot(self, *args): """ Prepare for providing the service. After this call, it may be requested by others. """ pass
[docs] def run(self): """ Called by reactor's loop when this object is enqueued as a reactor task. """ pass
[docs] def suspend(self): """ Suspend service. Object should somehow conserve its internal state, its service will not be used until the next call of ``wake_up`` method. """ pass
[docs] def wake_up(self): """ Wake up service. In this method, object should restore its internal state, and after this call its service can be requested by others again. """ pass
[docs] def die(self, exc): """ Exceptional state requires immediate termination of service. Probably no object will ever have need to call others' ``die`` method, it's intended for internal use only. """ pass
[docs] def halt(self): """ Terminate service. It will never be requested again, object can destroy its internal state, and free allocated resources. """ pass
[docs]class IReactorTask(object): """ Base class for all reactor tasks. """
[docs] def run(self): """ This method is called by reactor to perform task's actions. """ pass
[docs]class ISnapshotable(object): """ Base class for objects that can be saved into a snapshot. """
[docs] def save_state(self, parent): """ Create state of the object, and attach it to a parent snapshot node. :param ducky.interfaces.ISnapshotable parent: parent snapshot node. """ pass
[docs] def load_state(self, state): """ Restore state of the object. :param ducky.snapshot.SnapshotNode state: snapshot node containing saved state. """ pass
[docs]class IVirtualInterrupt(object): def __init__(self, machine): super(IVirtualInterrupt, self).__init__() self.machine = machine
[docs] def run(self, core): pass