com.atlassian.sal.core.executor
Class ThreadLocalDelegateExecutorService<C>

java.lang.Object
  extended by com.atlassian.sal.core.executor.ThreadLocalDelegateExecutorService<C>
All Implemented Interfaces:
Executor, ExecutorService
Direct Known Subclasses:
ThreadLocalDelegateScheduledExecutorService

public class ThreadLocalDelegateExecutorService<C>
extends Object
implements ExecutorService

Executor service that wraps executing callables and runnables in a wrapper that transfers the thread local state of the caller to the thread of the executing task.

Since:
2.0

Field Summary
protected  ThreadLocalContextManager<C> manager
           
 
Constructor Summary
ThreadLocalDelegateExecutorService(ThreadLocalContextManager<C> manager, ExecutorService delegate)
           
 
Method Summary
 boolean awaitTermination(long timeout, TimeUnit unit)
           
 void execute(Runnable runnable)
           
<T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>> callables)
           
<T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>> callables, long timeout, TimeUnit unit)
           
<T> T
invokeAny(Collection<? extends Callable<T>> callables)
           
<T> T
invokeAny(Collection<? extends Callable<T>> callables, long timeout, TimeUnit unit)
           
 boolean isShutdown()
           
 boolean isTerminated()
           
 void shutdown()
           
 List<Runnable> shutdownNow()
           
<T> Future<T>
submit(Callable<T> callable)
           
 Future<?> submit(Runnable runnable)
           
<T> Future<T>
submit(Runnable runnable, T t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager

protected final ThreadLocalContextManager<C> manager
Constructor Detail

ThreadLocalDelegateExecutorService

public ThreadLocalDelegateExecutorService(ThreadLocalContextManager<C> manager,
                                          ExecutorService delegate)
Method Detail

shutdown

public void shutdown()
Specified by:
shutdown in interface ExecutorService

shutdownNow

public List<Runnable> shutdownNow()
Specified by:
shutdownNow in interface ExecutorService

isShutdown

public boolean isShutdown()
Specified by:
isShutdown in interface ExecutorService

isTerminated

public boolean isTerminated()
Specified by:
isTerminated in interface ExecutorService

awaitTermination

public boolean awaitTermination(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
Specified by:
awaitTermination in interface ExecutorService
Throws:
InterruptedException

submit

public <T> Future<T> submit(Callable<T> callable)
Specified by:
submit in interface ExecutorService

submit

public <T> Future<T> submit(Runnable runnable,
                            T t)
Specified by:
submit in interface ExecutorService

submit

public Future<?> submit(Runnable runnable)
Specified by:
submit in interface ExecutorService

invokeAll

public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> callables)
                          throws InterruptedException
Specified by:
invokeAll in interface ExecutorService
Throws:
InterruptedException

invokeAll

public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> callables,
                                     long timeout,
                                     TimeUnit unit)
                          throws InterruptedException
Specified by:
invokeAll in interface ExecutorService
Throws:
InterruptedException

invokeAny

public <T> T invokeAny(Collection<? extends Callable<T>> callables)
            throws InterruptedException,
                   ExecutionException
Specified by:
invokeAny in interface ExecutorService
Throws:
InterruptedException
ExecutionException

invokeAny

public <T> T invokeAny(Collection<? extends Callable<T>> callables,
                       long timeout,
                       TimeUnit unit)
            throws InterruptedException,
                   ExecutionException,
                   TimeoutException
Specified by:
invokeAny in interface ExecutorService
Throws:
InterruptedException
ExecutionException
TimeoutException

execute

public void execute(Runnable runnable)
Specified by:
execute in interface Executor


Copyright © 2015 Atlassian. All rights reserved.