Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.6.0)

E13403-07

oracle.ide.model.concurrent
Class AsynchronousCallableCompletionService<T>

java.lang.Object
  extended by oracle.ide.model.concurrent.AsynchronousCallableCompletionService<T>
Type Parameters:
T - the types of results that the submitted Callables are to have.

public final class AsynchronousCallableCompletionService<T>
extends java.lang.Object

Wraps a CompletionService and provides an abstraction for submitting a set of Callables, along with a single callback class, CallableResultHandler, for processing the result/exception of every Callable.

Usage Example

 class MyAsyncProcessor
 {
    final static int NUMBER_OF_THREADS = 1000;
    CallableResultHandler<Boolean> callableHandlerImpl = new CallableResultHandler<Boolean>() 
    {
       public void onCompletion(Boolean resultFromASingleCallable) {
          // process result
       }

       public void onException(ExecutionException executionException) {
          // process exception
       }
    };
    AsynchronousCallableCompletionService<Boolean> theDecider =
       new AsynchronousCallableCompletionService<Boolean>(
                                Executors.newFixedThreadPool(NUMBER_OF_THREADS), callableHandlerImpl);

    MyAsyncProcessor(List<Callable<Boolean>> districts) {
       for (Callable<Boolean> district: districts) {
          theDecider.submit(district);
       }
    }
 }
 
 


Constructor Summary
AsynchronousCallableCompletionService(java.util.concurrent.ExecutorService executor, CallableResultHandler<T> asyncContentLevelCallback)
          Instantiates an AsynchronousCallableCompletionService that will use the provided executor to process Callables.
 
Method Summary
 boolean isShutdown()
          Whether the service is in a shutdown state.
 boolean isTerminated()
          Whether the service is in a terminated state.
 void shutdownNow(boolean mayInterruptIfRunning)
          Cancels all scheduled Callables including the ones currently in progress and shuts down the completion service.
 void submit(java.util.concurrent.Callable<T> task)
          Submits a callable that is to be scheduled with the completion service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsynchronousCallableCompletionService

public AsynchronousCallableCompletionService(java.util.concurrent.ExecutorService executor,
                                             CallableResultHandler<T> asyncContentLevelCallback)
Instantiates an AsynchronousCallableCompletionService that will use the provided executor to process Callables.

Parameters:
executor - the executor to be used with the completion service
asyncContentLevelCallback - the callback object for processing individual results
Method Detail

submit

public void submit(java.util.concurrent.Callable<T> task)
Submits a callable that is to be scheduled with the completion service. Should the Callable terminate without exceptions, CallableResultHandler#onCompletion(T) will be called. Otherwise, CallableResultHandler.onException(ExecutionException) will be called.

Parameters:
task - the callable task to be submitted for execution.
Throws:
RejectedExecutionException - when service is shut down.

shutdownNow

public void shutdownNow(boolean mayInterruptIfRunning)
Cancels all scheduled Callables including the ones currently in progress and shuts down the completion service. The semantics of the cancellation policy for every Future is the same as the semantics of mayInterruptIfRunning in Future.cancel(boolean). The underlying ExecutorService is shut down. A best-effort-only guarantee is made for currently executing tasks.

Parameters:
mayInterruptIfRunning -
See Also:
Future.cancel(boolean), ExecutorService.shutdownNow()

isShutdown

public boolean isShutdown()
Whether the service is in a shutdown state. If so, no furter tasks can be submitted. Currently submitted callables are not guaranteed to have terminated.

Returns:
true, if the service is shut down.
See Also:
ExecutorService.isShutdown()

isTerminated

public boolean isTerminated()
Whether the service is in a terminated state. A service is in a terminated state, if

Returns:
trueif the service is terminated.
See Also:
ExecutorService.isShutdown()

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.6.0)

E13403-07

Copyright © 1997, 2011, Oracle. All rights reserved.