Class NonBlockingMutexExecutor

  • All Implemented Interfaces:
    java.util.concurrent.Executor

    class NonBlockingMutexExecutor
    extends java.lang.Object
    implements java.util.concurrent.Executor
    Executor that provides mutual exclusion between the operations submitted to it, without blocking. If an operation is submitted to this executor while no other operation is running, it will run immediately. If an operation is submitted to this executor while another operation is running, it will be added to a queue of operations to run, and the executor will return. The thread currently running an operation will end up running the operation just submitted. Operations submitted to this executor should run fast, as they can end up running on other threads and interfere with the operation of other threads. This executor can also be used to address infinite recursion problems, as operations submitted recursively will run sequentially. Inspired by Public Domain CC0 code at h https://github.com/jroper/reactive-streams-servlet/tree/master/reactive-streams-servlet/src/main/java/org/reactivestreams/servlet
    • Constructor Detail

      • NonBlockingMutexExecutor

        NonBlockingMutexExecutor()
    • Method Detail

      • execute

        public void execute​(java.lang.Runnable command)
        Specified by:
        execute in interface java.util.concurrent.Executor
      • reportFailure

        private void reportFailure​(java.lang.Thread runner,
                                   java.lang.Throwable thrown)