pt.ua.concurrent
Class Future<T>

java.lang.Object
  extended by pt.ua.concurrent.Future<T>

public class Future<T>
extends java.lang.Object

Actor's Futures class.

This class handles future results from actor routines.

This class follows DbC(tm) methodology (Wikipedia). Where possible, contracts are implement with native's Java assert.

Version:
0.5, November 2011
Author:
Miguel Oliveira e Silva (mos@ua.pt)

Constructor Summary
Future(boolean isFunction)
          Constructs a new future (either for a function or a procedure).
 
Method Summary
 void done()
          Waits until the actor's routine attached to this future is done.
 boolean isFunction()
          Is this future applied to a function?
 T result()
          The result of the actor's function attached to this future.
 void setResult(T res)
          Sets the result of the actor's function attached to this future.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Future

public Future(boolean isFunction)
Constructs a new future (either for a function or a procedure).

Parameters:
isFunction - true if is a function future (with a result), or false for a procedure
Method Detail

isFunction

public boolean isFunction()
Is this future applied to a function?

Returns:
boolean true if is a function future, otherwise it is a procedure future

done

public void done()
Waits until the actor's routine attached to this future is done. This routine implements an eager remote invocation behavior.


result

public T result()
The result of the actor's function attached to this future. If necessary, it waits (done) until the function is done.

requires: isFunction()

Returns:
T the function's result

setResult

public void setResult(T res)
Sets the result of the actor's function attached to this future. This method should only be used by actor's!

requires: isFunction()

Parameters:
res - the function's result