public interface Invocable
A task (typically either a Runnable or Callable
that declares how it will behave when invoked:
Static methods and are provided that allow the current thread to be tagged
with a ThreadLocal to indicate if it has a blocking invocation type.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Invocable.InvocationType |
| Modifier and Type | Field and Description |
|---|---|
static ThreadLocal<Boolean> |
__nonBlocking |
| Modifier and Type | Method and Description |
|---|---|
static Runnable |
asPreferred(Runnable task,
Invocable.InvocationType preferredInvocationType)
wrap a task with the to indicate invocation type.
|
default Invocable.InvocationType |
getInvocationType() |
static Invocable.InvocationType |
getInvocationType(Object o)
Get the invocation type of an Object.
|
static void |
invokeNonBlocking(Runnable task)
Invoke a task with the calling thread, tagged to indicate
that it will not block.
|
static void |
invokePreferNonBlocking(Runnable task)
Invoke a task with the calling thread.
|
static void |
invokePreferred(Runnable task,
Invocable.InvocationType preferredInvocationType)
Invoke a task with the calling thread.
|
static boolean |
isNonBlockingInvocation()
Test if the current thread has been tagged as non blocking
|
static final ThreadLocal<Boolean> __nonBlocking
static boolean isNonBlockingInvocation()
static void invokeNonBlocking(Runnable task)
task - The task to invoke.static void invokePreferNonBlocking(Runnable task)
Invocable of Invocable.InvocationType.EITHER
then it is invoked with invokeNonBlocking(Runnable), to
indicate the type of invocation that has been assumed.task - The task to invoke.static void invokePreferred(Runnable task, Invocable.InvocationType preferredInvocationType)
Invocable of Invocable.InvocationType.EITHER
and the preferredInvocationType is not Invocable.InvocationType.BLOCKING
then it is invoked with invokeNonBlocking(Runnable).task - The task to invoke.preferredInvocationType - The invocation type to use if the task
does not indicate a preference.static Runnable asPreferred(Runnable task, Invocable.InvocationType preferredInvocationType)
Invocable of Invocable.InvocationType.EITHER
and the preferredInvocationType is not Invocable.InvocationType.BLOCKING
then it is wrapped with an invocation of invokeNonBlocking(Runnable).
otherwise the task itself is returned.task - The task to invoke.preferredInvocationType - The invocation type to use if the task
does not indicate a preference.static Invocable.InvocationType getInvocationType(Object o)
o - The object to check the invocation type of.Invocable, it is coerced and the getInvocationType()
used, otherwise Invocable.InvocationType.BLOCKING is returned.default Invocable.InvocationType getInvocationType()
Copyright © 1995–2017 Webtide. All rights reserved.