Package graphql.execution.reactive
Class NonBlockingMutexExecutor
- java.lang.Object
-
- graphql.execution.reactive.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
NonBlockingMutexExecutor.RunNode
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<NonBlockingMutexExecutor.RunNode>
last
-
Constructor Summary
Constructors Constructor Description NonBlockingMutexExecutor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(java.lang.Runnable command)
private void
reportFailure(java.lang.Thread runner, java.lang.Throwable thrown)
private void
run(NonBlockingMutexExecutor.RunNode current)
private void
runAll(NonBlockingMutexExecutor.RunNode next)
-
-
-
Field Detail
-
last
private final java.util.concurrent.atomic.AtomicReference<NonBlockingMutexExecutor.RunNode> last
-
-
Method Detail
-
execute
public void execute(java.lang.Runnable command)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
reportFailure
private void reportFailure(java.lang.Thread runner, java.lang.Throwable thrown)
-
run
private void run(NonBlockingMutexExecutor.RunNode current)
-
runAll
private void runAll(NonBlockingMutexExecutor.RunNode next)
-
-