back to API     back to index     prev     next  

Automatic Continuation in ProActive

Objectives

An Automatic Continuation is due to the propagation of a future outside the activity that has sent the corresponding request.

Automatic Continuations allow to pass in parameter or return as a result future objects(or objects containing a future) without blocking to wait the result object of the future. When the result is available on the object that originated the creation of the future, this object must update the result in all objects to which it passed the future.

Principles

Example

The following piece of code shows both cases: passing a future as parameter or as a result.

class C{
....

	public static void main(String[] args){

	......

	A a = newActive(A);
 	A b = newActive(B);

 	Result r1 = a.foo();   //r1 is a future
 	Result r2 = b.bar(r1); //r1 is passed as parameter
	Result r3 = b.bar2();  // see **

	........

	} 	//end of main

...
}	//end of class C

where

class A {

  ...
	public Result foo(){
	...
	}
  ...
} //end of class A

class B{
...
 	 public Result bar (Result r) {
	...
 	 }
  
  	public Result bar2 () {
   	 A a = newActive(A);
    	return a.foo();     // ** future is sent as a result
 	 }

} //end of class B

Illustration of an Automatic Continuation with a future passed as parameter


Let us say that some piece of code in main method of an object C calls method foo() on an instance of class A.



This calll is asynhronous and returns a future object Future_r1 of class Result.



Then method bar() is called on an instance of class B passing future Future_r1 as a parameter to the method



This calll is asynhronous and returns a future object Future_r2 of class Result. B needs the value of Future_r1 which is not yet available in order to return the result of method bar(), so it gets the future too.



The value of the result for the call to method foo is now available, so A updates the value of Future_r1



C updates the value of Future_r1 for B



B returns the value for the call to method bar() and updates the value of Future_r2 for C


Copyright © April 2004 INRIA All Rights Reserved.