GigaSpaces XAP 10.0.1 API

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

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

public class WaitForAllListener<T>
extends Object
implements 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, 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(AsyncResult<T> result)
          A callback when a result of an async invocation arrives.
 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,
                          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(AsyncResult<T> result)
Description copied from interface: AsyncFutureListener
A callback when a result of an async invocation arrives.

Specified by:
onResult in interface 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 XAP 10.0.1 API

Copyright © GigaSpaces.