Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members  

Future Class Template Reference

#include <Future.h>

Inheritance diagram for Future:

Waitable List of all members.

Public Types

typedef CountedPtr< ResultResultRef
 Reference counting holder for results.

typedef CountedPtr< CallableCallableRef
 Reference counting holder for results.


Public Methods

 Future (const CallableRef &c, Executor &executor)
virtual ~Future () throw ()
 Destroy the Future.

virtual void wait ()
virtual bool wait (unsigned long timeout)
ResultType getResult ()

Detailed Description

template<typename ResultType>
class ZThread::Future< ResultType >

Author:
Eric Crahen <crahen@cse.buffalo.edu>
Date:
<2002-06-10T09:21:16-0400>
Version:
2.2.3
A Future acts as a placeholder for a result that is being calculated, or a result that will be calculated. Think of this as an IOU for some value. Futures also allow you to take an exception thrown in one context (the context of the thread executing the task thats supposed to procude a result) and will propogate it to all thread wait()ing for a result from the Future.

Waiting

Waiting for a Future means to wait for the completion of a Callable task. When the Callable tasks reports a result or an exception, wait() will no longer block. If an exception was set, it will be thrown. If a result was set, it will be obtainable.

See also:
Waitable
Currently, there is an example in tests/FutureTests.cxx


Constructor & Destructor Documentation

Future const CallableRef   c,
Executor   executor
[inline]
 

Create a Future that will Execute the given Callable object by wrapping it with a Runnable and submitting it to an Executor.

Parameters:
c  - Callable to execute
executor  - Executor to submit the task to.
Precondition:
Currently, callables are passed by value.


Member Function Documentation

ResultType getResult   [inline]
 

Get the result from the future, this will block the caller until a result is ready. If the Callable has set an exception, that exception with be propogated to all waiters.

Returns :
ResultType

virtual bool wait unsigned long    timeout [inline, virtual]
 

Wait for the Future's Callable to finish producing a result or an excetion. If the timeout expires before the result is ready, return false.

See also:
Waitable::wait(unsigned long)

Reimplemented from Waitable.

virtual void wait   [inline, virtual]
 

Wait for the Future's Callable to finish producing a result or an excetion.

See also:
Waitable::wait()

Reimplemented from Waitable.


The documentation for this class was generated from the following file:
Generated on Tue Aug 27 07:43:12 2002 for ZThread by doxygen1.2.17