| | |
- __builtin__.object
-
- cothread.cothread.ThreadedEventQueue
- cothread.cothread.Timer
- cothread.cothread.EventBase(__builtin__.object)
-
- cothread.cothread.Event
- cothread.cothread.EventQueue
- cothread.cothread.Spawn
- exceptions.Exception
-
- cothread.cothread.Timedout
class Event(EventBase) |
| |
Any number of tasks can wait for an event to occur. A single value
can also be associated with the event. |
| |
- Method resolution order:
- Event
- EventBase
- __builtin__.object
Methods defined here:
- AbortWait(self)
- Called instead of performing a proper wait to release any resources
that might be consumed until the wait occurs.
- Reset(self)
- Resets the event (and erases the value).
- Signal(self, value=None)
- Signals the event. Any waiting tasks are scheduled to be woken.
- SignalException(self, exception)
- Signals the event with an exception: the next call to wait will
receive an exception instead of a normal return value.
- Wait(self, timeout=None)
- The caller will block until the event becomes true, or until the
timeout occurs if a timeout is specified. A Timeout exception is
raised if a timeout occurs.
- __init__(self, auto_reset=True)
- An event object is either signalled or reset. Any task can wait
for the object to become signalled, and it will be suspended until
this occurs.
The intial value can be specified, as can the behaviour on succesfully
signalling a process: if auto_reset=True is specified then only one
task at a time sees any individual signal on this object.
- __nonzero__(self)
- Tests whether the event is signalled.
Properties defined here:
- value
- get lambda self
Data and other attributes inherited from EventBase:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'EventBase' objects>
- list of weak references to the object (if defined)
|
class EventQueue(EventBase) |
| |
A queue of objects. A queue can also be treated as an iterator. |
| |
- Method resolution order:
- EventQueue
- EventBase
- __builtin__.object
Methods defined here:
- AbortWait(self)
- Called instead of performing a proper wait to release any resources
that might be consumed until the wait occurs.
- Signal(self, value)
- Adds the given value to the tail of the queue.
- Wait(self, timeout=None)
- Returns the next object from the queue, or raises a Timeout
exception if the timeout expires first.
- __init__(self)
- __iter__(self)
- An event queue can itself be treated as an iterator: this allows
event dispatching using a for loop, and provides some support for
combining queues.
- __len__(self)
- Returns the number of objects waiting on the queue.
- close(self)
- An event queue can be closed. This will cause waiting to raise
the StopIteration exception (once existing entries have been read),
and will prevent any further signals to the queue.
- next(self)
Data and other attributes inherited from EventBase:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'EventBase' objects>
- list of weak references to the object (if defined)
|
class Spawn(EventBase) |
| |
This class is used to wrap cooperative threads: every task (except
for main) managed by the scheduler should be an instance of this class. |
| |
- Method resolution order:
- Spawn
- EventBase
- __builtin__.object
Methods defined here:
- AbortWait(self)
- Called instead of performing a proper wait to release any resources
that might be consumed until the wait occurs.
- Wait(self, timeout=None)
- Waits until the task has completed. May raise an exception if the
task terminated with an exception and raise_on_wait was selected.
Can only be called once, as the result is deleted after call.
- __init__(self, function, *args, **kargs)
- The given function and arguments will be called as a new task.
All of the arguments will be be passed through to function, except for
the special keyword raise_on_wait which defaults to False.
If raise_on_wait is set then any exception raised during the
execution of this task will be postponed until Wait() is called. This
allows such exceptions to be caught without disturbing the normal
operation of the system. Otherwise any exception is reported.
Properties defined here:
- finished
- get lambda self
Data and other attributes inherited from EventBase:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'EventBase' objects>
- list of weak references to the object (if defined)
|
class ThreadedEventQueue(__builtin__.object) |
| |
An event queue designed to work with threads. |
| |
Methods defined here:
- Signal(self, value)
- Posts a value to the event queue. This can safely be called from
a thread or a cothread.
- Wait(self, timeout=None)
- Waits for a value to be written to the queue. This can safely be
called from either a cothread or another thread: the appropriate form
of cooperative or normal blocking will be selected automatically.
- __init__(self)
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'ThreadedEventQueue' objects>
- list of weak references to the object (if defined)
|
class Timer(__builtin__.object) |
| |
A cancellable one-shot or auto-retriggering timer. |
| |
Methods defined here:
- __init__(self, timeout, callback, retrigger=False)
- The callback will be called after the specified timeout. If
retrigger is set then the timer will automatically retrigger until
it is cancelled.
- cancel(self)
- Cancels the timer: the timer is guaranteed not to fire once this
call has been made.
- reset(self, timeout=None, retrigger=False)
- Resets the timer. If it hasn't fired yet then the timeout is reset
to the given timeout (or its original timeout by default). ???
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Timer' objects>
- list of weak references to the object (if defined)
| |