Eidolon
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Future Class Reference

Inherits object.

Collaboration diagram for Future:
Collaboration graph

Public Member Functions

def __init__ (self)
 
def setObject (self, obj)
 
def clear (self)
 
def isSet (self)
 
def isEmpty (self)
 
def getObjectWait (self, timeout=10.0)
 
def __call__ (self, timeout=10.0)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_value, tb)
 

Static Public Member Functions

def get (obj, timeout=10.0)
 

Public Attributes

 obj
 
 event
 

Detailed Description

An implementation of the Future Object design pattern. This acts as a proxy for a result from some concurrent task
which can be given to clients. When the task completes the result is given to the object, which can be retrieved
through the 'getObjectWait' function of the call () operator. If the result hasn't arrived yet then the caller will
block until it does, or when the optional timout period has elapsed. These objects work only for threads and not
between processes.

Futures can be used in a 'with' control block, such that they will send the client an exception if the block is
left without a result being sent or if an exception is thrown. This is useful in preventing client deadlock when
errors occur.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Member Function Documentation

◆ __call__()

def __call__ (   self,
  timeout = 10.0 
)
Same as getObjectWait().
Here is the call graph for this function:

◆ __enter__()

def __enter__ (   self)
Used to define with-blocks in which the Future must be given a value. If the block exits without a value set,
__exit__ will set the object to a FutureError indicating this. This also includes the case where the block
exits because of a raised exception, the details of which will be stored in the FutureError object.

◆ __exit__()

def __exit__ (   self,
  exc_type,
  exc_value,
  tb 
)
Sets the stored object to a FutureError if block exits without a value or because of a raised exception.
Here is the call graph for this function:

◆ clear()

def clear (   self)
Remove the internal object and clear the event.
Here is the caller graph for this function:

◆ get()

def get (   obj,
  timeout = 10.0 
)
static
Retrieve the object from `obj' if it's a Future, otherwise return `obj' itself. This is useful for methods which
may want to accept a Future containing an object or the object itself, depending on whether the use context is
concurrent or not. The `timeout' value is only used if `obj' is a Future, and must then be a positive float.

◆ getObjectWait()

def getObjectWait (   self,
  timeout = 10.0 
)
Return the stored object, waiting `timeout' seconds for the object to be set, returning None if this doesn't
occur in this time. If the object is present and is an exception, this is raised instead. The `timeout'
value therefore must be a positive float or None to indicate indefinite waiting. If a timeout value is given
and the return result is None, the timeout time was reached if isSet() returns False at this point, otherwise
None was the set value.
Here is the caller graph for this function:

◆ isEmpty()

def isEmpty (   self)
Returns True if there is no result and the event is not set.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSet()

def isSet (   self)
Returns True if the event has been set, ie. a result is stored.
Here is the caller graph for this function:

◆ setObject()

def setObject (   self,
  obj 
)
Set the internal stored object to `obj' and set the event.
Here is the caller graph for this function:

Member Data Documentation

◆ event

event

◆ obj

obj

The documentation for this class was generated from the following file: