GigaSpaces XAP 9.1 API

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

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

public class WaitForAnyListener<T>
extends Object
implements AsyncFutureListener<T>

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

Author:
kimchy

Constructor Summary
WaitForAnyListener(int numberOfResults)
          Constructs a new listener with the number of executions this listener will be set on.
WaitForAnyListener(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.
 T waitForResult()
          Waits for any result indefently.
 T waitForResult(long timeout, TimeUnit unit)
          Waits for any result 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

WaitForAnyListener

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


WaitForAnyListener

public WaitForAnyListener(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 T waitForResult()
                throws InterruptedException
Waits for any result indefently.

Throws:
InterruptedException

waitForResult

public T waitForResult(long timeout,
                       TimeUnit unit)
                throws InterruptedException,
                       TimeoutException
Waits for any result for the given time period.

Throws:
InterruptedException
TimeoutException

GigaSpaces XAP 9.1 API

Copyright © GigaSpaces.