public final class TtlCallable<V> extends Object implements Callable<V>
TtlCallable decorate Callable, so as to get TransmittableThreadLocal
and transmit it to the time of Callable execution, needed when use Callable to thread pool.
Use factory method get(Callable) to get decorated instance.
Executor,
ExecutorService,
ThreadPoolExecutor,
ScheduledThreadPoolExecutor,
Executors,
CompletionService,
ExecutorCompletionService| Modifier and Type | Method and Description |
|---|---|
V |
call()
wrap method
Callable.call(). |
static <T> TtlCallable<T> |
get(Callable<T> callable)
Factory method, wrapper input
Callable to TtlCallable. |
static <T> TtlCallable<T> |
get(Callable<T> callable,
boolean releaseTtlValueReferenceAfterCall)
Factory method, wrapper input
Callable to TtlCallable. |
static <T> TtlCallable<T> |
get(Callable<T> callable,
boolean releaseTtlValueReferenceAfterCall,
boolean idempotent)
Factory method, wrapper input
Callable to TtlCallable. |
Callable<V> |
getCallable() |
static <T> List<TtlCallable<T>> |
gets(Collection<? extends Callable<T>> tasks)
wrapper input
Callable Collection to TtlCallable Collection. |
static <T> List<TtlCallable<T>> |
gets(Collection<? extends Callable<T>> tasks,
boolean releaseTtlValueReferenceAfterCall)
wrapper input
Callable Collection to TtlCallable Collection. |
static <T> List<TtlCallable<T>> |
gets(Collection<? extends Callable<T>> tasks,
boolean releaseTtlValueReferenceAfterCall,
boolean idempotent)
wrapper input
Callable Collection to TtlCallable Collection. |
public V call() throws Exception
Callable.call().public static <T> TtlCallable<T> get(Callable<T> callable)
public static <T> TtlCallable<T> get(Callable<T> callable, boolean releaseTtlValueReferenceAfterCall)
callable - input CallablereleaseTtlValueReferenceAfterCall - release TTL value reference after run, avoid memory leak even if TtlRunnable is referred.Callablepublic static <T> TtlCallable<T> get(Callable<T> callable, boolean releaseTtlValueReferenceAfterCall, boolean idempotent)
callable - input CallablereleaseTtlValueReferenceAfterCall - release TTL value reference after run, avoid memory leak even if TtlRunnable is referred.idempotent - is idempotent or not. true will cover up bugs! DO NOT set, only when you know why.Callablepublic static <T> List<TtlCallable<T>> gets(Collection<? extends Callable<T>> tasks)
Callable Collection to TtlCallable Collection.tasks - task to be wrappedCallablepublic static <T> List<TtlCallable<T>> gets(Collection<? extends Callable<T>> tasks, boolean releaseTtlValueReferenceAfterCall)
Callable Collection to TtlCallable Collection.tasks - task to be wrappedreleaseTtlValueReferenceAfterCall - release TTL value reference after run, avoid memory leak even if TtlRunnable is referred.Callablepublic static <T> List<TtlCallable<T>> gets(Collection<? extends Callable<T>> tasks, boolean releaseTtlValueReferenceAfterCall, boolean idempotent)
Callable Collection to TtlCallable Collection.tasks - task to be wrappedreleaseTtlValueReferenceAfterCall - release TTL value reference after run, avoid memory leak even if TtlRunnable is referred.idempotent - is idempotent or not. true will cover up bugs! DO NOT set, only when you know why.CallableCopyright © 2013–2016 Alibaba. All rights reserved.