Top Description Inners Fields Methods
org.eclipse.jetty.util.thread

public Interface Invocable

Known Direct Subinterfaces
org.eclipse.jetty.util.thread.Invocable.Task, org.eclipse.jetty.util.thread.Invocable.Callable, org.eclipse.jetty.util.Blocker.Runnable, org.eclipse.jetty.util.Blocker.Callback, org.eclipse.jetty.util.Callback
Known Direct Implementers
org.eclipse.jetty.util.thread.SerializedInvoker.Link

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static enum
Invocable.InvocationType

The behavior of an Invocable when it is invoked.

public static class
public static interface

Field Summary

Modifier and TypeField and Description
public static final ThreadLocal<Boolean>
public static final Runnable

Method Summary

Modifier and TypeMethod and Description
public static Invocable.InvocationType

Returns:

The combination of both type, where any tendency to block overrules any non blocking.
combine
(Invocable.InvocationType
A type
it1
,
Invocable.InvocationType
Another type
it2
)

Combine two invocation type.

public static Runnable

Returns:

the combined Runnable with a combined InvocationType.
combine
(Runnable...
the Runnables to combine
runnables
)

Combine Runnables into a single Runnable that sequentially calls the others.

public static Invocable.Task

Returns:

a new Task
from
(Invocable.InvocationType
the InvocationType
type
,
Runnable
the Runnable
task
)

Creates a Task from the given InvocationType and Runnable.

public static Invocable.InvocationType

Returns:

If the object is an Invocable, it is coerced and the getInvocationType() used, otherwise InvocationType#BLOCKING is returned.
getInvocationType
(Object
The object to check the invocation type of.
o
)

Get the invocation type of an Object.

public default Invocable.InvocationType

Returns:

The InvocationType of this object
getInvocationType
()

public static void
invokeNonBlocking(Runnable
The task to invoke.
task
)

Invoke a task with the calling thread, tagged to indicate that it will not block.

public static boolean

Returns:

True if the task the current thread is running has indicated that it will not block.
isNonBlockingInvocation
()

Test if the current thread has been tagged as non blocking

Field Detail

__nonBlockingback to summary
public static final ThreadLocal<Boolean> __nonBlocking
NOOPback to summary
public static final Runnable NOOP

Method Detail

combineback to summary
public static Invocable.InvocationType combine(Invocable.InvocationType it1, Invocable.InvocationType it2)

Combine two invocation type.

Parameters
it1:Invocable.InvocationType

A type

it2:Invocable.InvocationType

Another type

Returns:Invocable.InvocationType

The combination of both type, where any tendency to block overrules any non blocking.

combineback to summary
public static Runnable combine(Runnable... runnables)

Combine Runnables into a single Runnable that sequentially calls the others.

Parameters
runnables:Runnable[]

the Runnables to combine

Returns:Runnable

the combined Runnable with a combined InvocationType.

fromback to summary
public static Invocable.Task from(Invocable.InvocationType type, Runnable task)

Creates a Task from the given InvocationType and Runnable.

Parameters
type:Invocable.InvocationType

the InvocationType

task:Runnable

the Runnable

Returns:Invocable.Task

a new Task

getInvocationTypeback to summary
public static Invocable.InvocationType getInvocationType(Object o)

Get the invocation type of an Object.

Parameters
o:Object

The object to check the invocation type of.

Returns:Invocable.InvocationType

If the object is an Invocable, it is coerced and the getInvocationType() used, otherwise InvocationType#BLOCKING is returned.

getInvocationTypeback to summary
public default Invocable.InvocationType getInvocationType()
Returns:Invocable.InvocationType

The InvocationType of this object

invokeNonBlockingback to summary
public static void invokeNonBlocking(Runnable task)

Invoke a task with the calling thread, tagged to indicate that it will not block.

Parameters
task:Runnable

The task to invoke.

isNonBlockingInvocationback to summary
public static boolean isNonBlockingInvocation()

Test if the current thread has been tagged as non blocking

Returns:boolean

True if the task the current thread is running has indicated that it will not block.

org.eclipse.jetty.util.thread back to summary

public Interface Invocable.Callable

extends Invocable

Field Summary

Inherited from org.eclipse.jetty.util.thread.Invocable:
__nonBlockingNOOP

Method Summary

Modifier and TypeMethod and Description
public void
call()

Inherited from org.eclipse.jetty.util.thread.Invocable:
combinecombinefromgetInvocationTypegetInvocationTypeinvokeNonBlockingisNonBlockingInvocation

Method Detail

callback to summary
public void call() throws Exception
org.eclipse.jetty.util.thread back to summary

public final Enum Invocable.InvocationType

extends Enum<Invocable.InvocationType>
Class Inheritance

The behavior of an Invocable when it is invoked.

Typically, Runnables or org.eclipse.jetty.util.Callbacks declare their invocation type; this information is then used by the code that should invoke the Runnable or Callback to decide whether to invoke it directly, or submit it to a thread pool to be invoked by a different thread.

Field Summary

Modifier and TypeField and Description
public static final Invocable.InvocationType
BLOCKING

Invoking the Invocable may block the invoker thread, and the invocation may be performed immediately (possibly blocking the invoker thread) or deferred to a later time, for example by submitting the Invocable to a thread pool.

public static final Invocable.InvocationType
EITHER

Invoking the Invocable may block the invoker thread, but the invocation cannot be deferred to a later time, differently from BLOCKING.

public static final Invocable.InvocationType
NON_BLOCKING

Invoking the Invocable does not block the invoker thread, and the invocation may be performed immediately in the invoker thread.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Invocable.InvocationType
public static Invocable.InvocationType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BLOCKINGback to summary
public static final Invocable.InvocationType BLOCKING

Invoking the Invocable may block the invoker thread, and the invocation may be performed immediately (possibly blocking the invoker thread) or deferred to a later time, for example by submitting the Invocable to a thread pool.

This invocation type is suitable for Invocables that call application code, for example to process an HTTP request.

EITHERback to summary
public static final Invocable.InvocationType EITHER

Invoking the Invocable may block the invoker thread, but the invocation cannot be deferred to a later time, differently from BLOCKING.

This invocation type is suitable for Invocables that themselves perform the non-deferrable action in a non-blocking way, thus advancing a possibly stalled system.

NON_BLOCKINGback to summary
public static final Invocable.InvocationType NON_BLOCKING

Invoking the Invocable does not block the invoker thread, and the invocation may be performed immediately in the invoker thread.

This invocation type is suitable for Invocables that call implementation code that is guaranteed to never block the invoker thread.

Constructor Detail

InvocationTypeback to summary
private InvocationType()

Method Detail

valueOfback to summary
public static Invocable.InvocationType valueOf(String name)
valuesback to summary
public static Invocable.InvocationType[] values()
org.eclipse.jetty.util.thread back to summary

public Class Invocable.ReadyTask

extends Object
implements Task
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.thread.Invocable.Task, java.lang.Runnable, org.eclipse.jetty.util.thread.Invocable

A Runnable decorated with an InvocationType.

Field Summary

Modifier and TypeField and Description
private final Runnable
private final Invocable.InvocationType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Invocable.InvocationType
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

taskback to summary
private final Runnable task
typeback to summary
private final Invocable.InvocationType type

Constructor Detail

ReadyTaskback to summary
public ReadyTask(Invocable.InvocationType type, Runnable task)

Method Detail

getInvocationTypeback to summary
public Invocable.InvocationType getInvocationType()

Overrides default org.eclipse.jetty.util.thread.Invocable.getInvocationType.

Returns:Invocable.InvocationType

Doc from org.eclipse.jetty.util.thread.Invocable.getInvocationType.

The InvocationType of this object

Annotations
@Override
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.eclipse.jetty.util.thread back to summary

public Interface Invocable.Task

extends Invocable, Runnable
Known Direct Implementers
org.eclipse.jetty.util.thread.Invocable.ReadyTask

A task with an InvocationType.

Field Summary

Inherited from org.eclipse.jetty.util.thread.Invocable:
__nonBlockingNOOP

Method Summary

Inherited from java.lang.Runnable:
run
Inherited from org.eclipse.jetty.util.thread.Invocable:
combinecombinefromgetInvocationTypegetInvocationTypeinvokeNonBlockingisNonBlockingInvocation