Package org.eclipse.jetty.util.thread
Interface Invocable
-
- All Known Subinterfaces:
Callback
- All Known Implementing Classes:
Callback.Completable,Callback.Nested,CompletableCallback,CountingCallback,FutureCallback,IteratingCallback,IteratingNestedCallback,SharedBlockingCallback.Blocker
public interface InvocableA task (typically either a
RunnableorCallablethat declares how it will behave when invoked:- blocking, the invocation will certainly block (e.g. performs blocking I/O)
- non-blocking, the invocation will certainly not block
- either, the invocation may block
Static methods and are provided that allow the current thread to be tagged with a
ThreadLocalto indicate if it has a blocking invocation type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classInvocable.InvocationType
-
Field Summary
Fields Modifier and Type Field Description static ThreadLocal<Boolean>__nonBlocking
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default Invocable.InvocationTypegetInvocationType()static Invocable.InvocationTypegetInvocationType(Object o)Get the invocation type of an Object.static voidinvokeNonBlocking(Runnable task)Invoke a task with the calling thread, tagged to indicate that it will not block.static booleanisNonBlockingInvocation()Test if the current thread has been tagged as non blocking
-
-
-
Field Detail
-
__nonBlocking
static final ThreadLocal<Boolean> __nonBlocking
-
-
Method Detail
-
isNonBlockingInvocation
static boolean isNonBlockingInvocation()
Test if the current thread has been tagged as non blocking- Returns:
- True if the task the current thread is running has indicated that it will not block.
-
invokeNonBlocking
static void invokeNonBlocking(Runnable task)
Invoke a task with the calling thread, tagged to indicate that it will not block.- Parameters:
task- The task to invoke.
-
getInvocationType
static Invocable.InvocationType getInvocationType(Object o)
Get the invocation type of an Object.- Parameters:
o- The object to check the invocation type of.- Returns:
- If the object is an Invocable, it is coerced and the
getInvocationType()used, otherwiseInvocable.InvocationType.BLOCKINGis returned.
-
getInvocationType
default Invocable.InvocationType getInvocationType()
- Returns:
- The InvocationType of this object
-
-