Interface Invocable

All Known Subinterfaces:
Blocker.Callback, Blocker.Runnable, Callback, Callback.Completing, Handler, Handler.Collection, Handler.Container, Handler.Singleton, HandlerContainer, HttpChannel, HttpStream, Invocable.Callable, Invocable.Task, Request.Handler
All Known Implementing Classes:
AbstractConnection, AbstractHandler, AbstractHandlerContainer, AbstractMetaDataConnection, ALPNClientConnection, ALPNServerConnection, AsyncMiddleManServlet.ProxyReader, AsyncMiddleManServlet.ProxyResponseListener, AsyncProxyServlet.StreamReader, BufferedResponseHandler, Callback.Completable, Callback.Nested, ClientQuicConnection, CompletionStreamWrapper, ConditionalHandler, ConditionalHandler.Abstract, ConditionalHandler.DontHandle, ConditionalHandler.ElseNext, ConditionalHandler.Reject, ConditionalHandler.SkipNext, ConnectHandler, ConnectHandler.DownstreamConnection, ConnectHandler.UpstreamConnection, ConstraintSecurityHandler, ContentCopier, ContentSourceConsumer, ContextHandler, ContextHandlerCollection, ContextRequest, ControlFlusher, CountingCallback, CrossOriginHandler, DebugHandler, DecoderStreamConnection, DefaultHandler, DelayedHandler, DemandingFlusher, EagerFormHandler, EncoderStreamConnection, ErrorHandler, ErrorHandler, ErrorPageErrorHandler, EventsHandler, FastCGIProxyHandler, FragmentExtension.FragmentingDemandingFlusher, FrameFlusher, FutureCallback, GracefulHandler, GzipHandler, GzipResponseAndCallback, Handler.Abstract, Handler.Abstract.NonBlocking, Handler.AbstractContainer, Handler.Sequence, Handler.Wrapper, HotSwapHandler, HTTP2Connection, HTTP2Flusher, HTTP2ServerConnection, HTTP2Session.Entry, HTTP2Stream, HTTP3StreamConnection, HttpChannelState, HttpChannelState.ChannelResponse, HttpConnection, HttpConnection.HttpStreamOverHTTP1, HttpConnectionOverFCGI, HttpConnectionOverHTTP, HttpDestination, HttpSpiContextHandler, HttpStream.Wrapper, HttpStreamOverFCGI, HttpStreamOverHTTP2, IdleTimeoutHandler, InetAccessHandler, InstructionFlusher, InstructionStreamConnection, Invocable.ReadyTask, IteratingCallback, IteratingNestedCallback, LatencyRecordingHandler, MessageFlusher, MovedContextHandler, NegotiatingClientConnection, NegotiatingServerConnection, PathMappingsHandler, ProxyHandler, ProxyHandler.Forward, ProxyHandler.ProxyResponseListener, ProxyHandler.Reverse, ProxyProtocolClientConnectionFactory.ProxyProtocolConnection, QoSHandler, QuicConnection, ReHandlingErrorHandler, ReHandlingErrorHandler.ByHttpStatus, ResourceHandler, ResourceHandler.ResourceContext, RewriteHandler, SecuredRedirectHandler, SecurityHandler, SecurityHandler.PathMapped, SendHandlerCallback, Server, ServerFCGIConnection, ServerQuicConnection, ServerWebSocketContainer, ServletContextHandler, ServletContextRequest, ServletHandler, SessionHandler, SessionHandler, SharedBlockingCallback.Blocker, ShutdownHandler, SizeLimitHandler, SslConnection, StatisticsHandler, StatisticsHandler.MinimumDataRateHandler, ThreadLimitHandler, TryPathsHandler, UnidirectionalStreamConnection, WebAppContext, WebSocketConnection, WebSocketUpgradeHandler, WebSocketUpgradeHandler

public interface Invocable

A task (typically either a Runnable or Invocable.Callable that 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 ThreadLocal to indicate if it has a blocking invocation type.

  • Field Details

  • Method Details

    • from

      Creates a Invocable.Task from the given InvocationType and Runnable.

      Parameters:
      type - the InvocationType
      task - the Runnable
      Returns:
      a new Task
    • 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.
    • combine

      Combine two invocation type.
      Parameters:
      it1 - A type
      it2 - Another type
      Returns:
      The combination of both type, where any tendency to block overrules any non blocking.
    • 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, otherwise Invocable.InvocationType.BLOCKING is returned.
    • getInvocationType

      default Invocable.InvocationType getInvocationType()
      Returns:
      The InvocationType of this object
    • combine

      static Runnable combine(Runnable... runnables)
      Combine Runnables into a single Runnable that sequentially calls the others.
      Parameters:
      runnables - the Runnables to combine
      Returns:
      the combined Runnable with a combined Invocable.InvocationType.