GigaSpaces - Open Spaces

org.openspaces.core.executor.support
Class WaitForAllListener<T>

java.lang.Object
  extended by org.openspaces.core.executor.support.WaitForAllListener<T>
All Implemented Interfaces:
com.gigaspaces.async.AsyncFutureListener<T>

public class WaitForAllListener<T>
extends Object
implements com.gigaspaces.async.AsyncFutureListener<T>

A listener that can be used to set on several execution and then wait for all the results (using waitForResult(). The number of executions needs to be known in advance and set in the constructor.

Author:
kimchy

Constructor Summary
WaitForAllListener(int numberOfResults)
          Constructs a new listener with the number of executions this listener will be set on.
WaitForAllListener(int numberOfResults, com.gigaspaces.async.AsyncFutureListener<T> listener)
          Constructs a new listener with the number of executions this listener will be set on with an optional delegate listener.
 
Method Summary
 void onResult(com.gigaspaces.async.AsyncResult<T> result)
           
 Future<T>[] waitForResult()
          Waits for all the results indefently.
 Future<T>[] waitForResult(long timeout, TimeUnit unit)
          Waits for all the results for the given time period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WaitForAllListener

public WaitForAllListener(int numberOfResults)
Constructs a new listener with the number of executions this listener will be set on.


WaitForAllListener

public WaitForAllListener(int numberOfResults,
                          com.gigaspaces.async.AsyncFutureListener<T> listener)
Constructs a new listener with the number of executions this listener will be set on with an optional delegate listener.

Method Detail

onResult

public void onResult(com.gigaspaces.async.AsyncResult<T> result)
Specified by:
onResult in interface com.gigaspaces.async.AsyncFutureListener<T>

waitForResult

public Future<T>[] waitForResult()
                          throws InterruptedException
Waits for all the results indefently. The futures retured all are done.

Throws:
InterruptedException

waitForResult

public Future<T>[] waitForResult(long timeout,
                                 TimeUnit unit)
                          throws InterruptedException
Waits for all the results for the given time period.

Throws:
InterruptedException

GigaSpaces - Open Spaces

Copyright © GigaSpaces.