org.objectweb.proactive.core.body.future
Class FutureProxy

java.lang.Object
  |
  +--org.objectweb.proactive.core.body.future.FutureProxy
All Implemented Interfaces:
Future, LocalFuture, Proxy, java.io.Serializable

public class FutureProxy
extends java.lang.Object
implements Future, Proxy, java.io.Serializable

This proxy class manages the semantic of future objects

Author:
Julien Vayssi?re - INRIA
See Also:
Proxy, Serialized Form

Field Summary
protected  boolean continuation
          To mark the proxy before sending this future by parameter or by result
protected  UniqueID creatorID
          UniqueID of the body which create this future
protected  long ID
          ID of the future In fact, the sequence number of the request that generate this future
protected  boolean isAvailable
          This flag indicates the status of the future object
protected  boolean isException
          Indicates if the returned object is an exception
protected  boolean migration
          To mark the Proxy before migration Usually, the Proxy cannot be serialized if the result is not available (no automatic continuation) but if we migrate, we don't want to wait for the result
static int RECYCLE_POOL_SIZE
          The size of the pool we use for recycling FutureProxy objects.
protected  UniqueID senderID
          Unique ID of the sender (in case of automatic continuation).
protected  java.lang.Object target
          The object the proxy sends calls to
 
Constructor Summary
FutureProxy()
          As this proxy does not create a reified object (as opposed to BodyProxy for example), it is the noargs constructor that is usually called.
FutureProxy(ConstructorCall c, java.lang.Object[] p)
          This constructor is provided for compatibility with other proxies.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
protected  void finalize()
           
static int futureLength(java.lang.Object future)
           
 UniqueID getCreatorID()
          To get the creatorID.
static FutureEventProducer getFutureEventProducer()
          Returns the FutureEventProducer that is responsible for the FutureProxys of this VM.
static FutureProxy getFutureProxy()
           
 long getID()
          To get the sequence id of this future.
 java.lang.Throwable getRaisedException()
          Returns the result this future is for as an exception if an exception has been raised or null if the result is not an exception.
 java.lang.Object getResult()
          Returns the result this future is for.
 boolean isAwaited()
          Tests the status of the returned object
static boolean isAwaited(java.lang.Object obj)
          Tests if the object obj is awaited or not.
 void receiveReply(java.lang.Object obj)
          Invoked by a thread of the skeleton that performed the service in order to tie the result object to the proxy.
 java.lang.Object reify(MethodCall c)
          Blocks until the future object is available, then executes Call c on the now-available object.
 void setContinuationTag()
           
 void setCreatorID(UniqueID i)
          To set the creatorID, ie the UniqueID of the body which create this future
 void setID(long l)
          To set the sequence id of this future.
protected  void setMigrationTag()
           
 void setResult(java.lang.Object o)
           
 void setSenderID(UniqueID i)
          To set the senderID, ie the UniqueID of the body that will send this future, in case of automatic continuation.
 void unsetContinuationTag()
           
protected  void unsetMigrationTag()
           
 void waitFor()
          Blocks the calling thread until the future object is available.
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECYCLE_POOL_SIZE

public static final int RECYCLE_POOL_SIZE
The size of the pool we use for recycling FutureProxy objects.

See Also:
Constant Field Values

target

protected java.lang.Object target
The object the proxy sends calls to


migration

protected boolean migration
To mark the Proxy before migration Usually, the Proxy cannot be serialized if the result is not available (no automatic continuation) but if we migrate, we don't want to wait for the result


continuation

protected boolean continuation
To mark the proxy before sending this future by parameter or by result


creatorID

protected UniqueID creatorID
UniqueID of the body which create this future


ID

protected long ID
ID of the future In fact, the sequence number of the request that generate this future


senderID

protected UniqueID senderID
Unique ID of the sender (in case of automatic continuation).


isAvailable

protected boolean isAvailable
This flag indicates the status of the future object


isException

protected boolean isException
Indicates if the returned object is an exception

Constructor Detail

FutureProxy

public FutureProxy()
            throws ConstructionOfReifiedObjectFailedException
As this proxy does not create a reified object (as opposed to BodyProxy for example), it is the noargs constructor that is usually called.


FutureProxy

public FutureProxy(ConstructorCall c,
                   java.lang.Object[] p)
            throws ConstructionOfReifiedObjectFailedException
This constructor is provided for compatibility with other proxies. More precisely, this permits proxy instanciation via the Meta.newMeta method.

Method Detail

isAwaited

public static boolean isAwaited(java.lang.Object obj)
Tests if the object obj is awaited or not. Always returns false if obj is not a future object.


getFutureProxy

public static FutureProxy getFutureProxy()

getFutureEventProducer

public static FutureEventProducer getFutureEventProducer()
Returns the FutureEventProducer that is responsible for the FutureProxys of this VM. Listeners can register themselves here.


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

receiveReply

public void receiveReply(java.lang.Object obj)
                  throws java.io.IOException
Invoked by a thread of the skeleton that performed the service in order to tie the result object to the proxy. If the execution of the call raised an exception, this exception is put into an object of class InvocationTargetException and returned, just like for any returned object

Specified by:
receiveReply in interface LocalFuture
java.io.IOException

getRaisedException

public java.lang.Throwable getRaisedException()
Returns the result this future is for as an exception if an exception has been raised or null if the result is not an exception. The method blocks until the result is available.

Specified by:
getRaisedException in interface Future
Returns:
the exception raised once available or null if no exception.

getResult

public java.lang.Object getResult()
Returns the result this future is for. The method blocks until the future is available

Specified by:
getResult in interface Future
Returns:
the result of this future object once available.

setResult

public void setResult(java.lang.Object o)

isAwaited

public boolean isAwaited()
Tests the status of the returned object

Specified by:
isAwaited in interface Future
Returns:
true if the future object is NOT yet available, false if it is.

waitFor

public void waitFor()
Blocks the calling thread until the future object is available.

Specified by:
waitFor in interface Future

getID

public long getID()
Description copied from interface: Future
To get the sequence id of this future.

Specified by:
getID in interface Future

setID

public void setID(long l)
Description copied from interface: Future
To set the sequence id of this future.

Specified by:
setID in interface Future

setCreatorID

public void setCreatorID(UniqueID i)
Description copied from interface: Future
To set the creatorID, ie the UniqueID of the body which create this future

Specified by:
setCreatorID in interface Future

getCreatorID

public UniqueID getCreatorID()
Description copied from interface: Future
To get the creatorID.

Specified by:
getCreatorID in interface Future

setSenderID

public void setSenderID(UniqueID i)
Description copied from interface: Future
To set the senderID, ie the UniqueID of the body that will send this future, in case of automatic continuation.

Specified by:
setSenderID in interface Future

reify

public java.lang.Object reify(MethodCall c)
                       throws java.lang.reflect.InvocationTargetException
Blocks until the future object is available, then executes Call c on the now-available object. As future and process behaviors are mutually exclusive, we know that the invocation of a method on a future objects cannot lead to wait-by necessity. Thus, we can propagate all exceptions raised by this invocation

Specified by:
reify in interface Proxy
Parameters:
c - The MethodCall object corresponding to the method
Returns:
The object returned by the method [wrapper class if it is a primitive or null if no return]
Throws:
java.lang.reflect.InvocationTargetException - If the invokation of the method represented by the Call object c on the reified object throws an exception, this exception is thrown as-is here. The stub then throws this exception to the calling thread after checking that it is declared in the throws clause of the reified method. Otherwise, the stub does nothing except print a message on System.err (or out ?).

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

setMigrationTag

protected void setMigrationTag()

unsetMigrationTag

protected void unsetMigrationTag()

setContinuationTag

public void setContinuationTag()

unsetContinuationTag

public void unsetContinuationTag()

futureLength

public static int futureLength(java.lang.Object future)


Copyright © April 2004 INRIA All Rights Reserved.