SpinExecutorService Class — netty Architecture
Architecture documentation for the SpinExecutorService class in BurstCostExecutorsBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e1d20ecf_b9ac_4de1_4575_dd9260dd6753["SpinExecutorService"] b13bc1c1_6503_8c67_bdc7_874bea111591["BurstCostExecutorsBenchmark.java"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|defined in| b13bc1c1_6503_8c67_bdc7_874bea111591 85ceb04d_6d16_20b0_4aaf_1a8d046a2bea["SpinExecutorService()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| 85ceb04d_6d16_20b0_4aaf_1a8d046a2bea acd9ae03_5540_8a87_ff13_29bd36434ae9["shutdown()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| acd9ae03_5540_8a87_ff13_29bd36434ae9 baa61574_d647_cffb_8cae_9a0d64814042["shutdownNow()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| baa61574_d647_cffb_8cae_9a0d64814042 9b2a08cb_66f9_6863_9269_e82725bd6615["isShutdown()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| 9b2a08cb_66f9_6863_9269_e82725bd6615 936393a3_4be1_63a3_0d2b_5e11dbd23fcc["isTerminated()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| 936393a3_4be1_63a3_0d2b_5e11dbd23fcc 90001a18_3b92_d42a_e9a0_5ca0f18d2b5c["awaitTermination()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| 90001a18_3b92_d42a_e9a0_5ca0f18d2b5c 608ffc08_fbe7_90db_a514_0d3e7b0a9132["submit()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| 608ffc08_fbe7_90db_a514_0d3e7b0a9132 08e1d543_c727_8d47_70d7_673595405909["invokeAll()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| 08e1d543_c727_8d47_70d7_673595405909 d3dd33dc_f291_fd56_9f11_a66882b099d9["T()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| d3dd33dc_f291_fd56_9f11_a66882b099d9 013e0add_b983_534c_ed80_88183c7cfc6f["execute()"] e1d20ecf_b9ac_4de1_4575_dd9260dd6753 -->|method| 013e0add_b983_534c_ed80_88183c7cfc6f
Relationship Graph
Source Code
microbench/src/main/java/io/netty/microbench/concurrent/BurstCostExecutorsBenchmark.java lines 59–166
private static final class SpinExecutorService implements ExecutorService {
private static final Runnable POISON_PILL = new Runnable() {
@Override
public void run() {
}
};
private final Queue<Runnable> tasks;
private final AtomicBoolean poisoned = new AtomicBoolean();
private final Thread executorThread;
SpinExecutorService(int maxTasks) {
tasks = PlatformDependent.newFixedMpscQueue(maxTasks);
executorThread = new Thread(new Runnable() {
@Override
public void run() {
final Queue<Runnable> tasks = SpinExecutorService.this.tasks;
Runnable task;
while ((task = tasks.poll()) != POISON_PILL) {
if (task != null) {
task.run();
}
}
}
});
executorThread.start();
}
@Override
public void shutdown() {
if (poisoned.compareAndSet(false, true)) {
while (!tasks.offer(POISON_PILL)) {
// Just try again
}
try {
executorThread.join();
} catch (InterruptedException e) {
//We're quite trusty :)
}
}
}
@Override
public List<Runnable> shutdownNow() {
throw new UnsupportedOperationException();
}
@Override
public boolean isShutdown() {
throw new UnsupportedOperationException();
}
@Override
public boolean isTerminated() {
throw new UnsupportedOperationException();
}
@Override
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
throw new UnsupportedOperationException();
}
@Override
public <T> Future<T> submit(Callable<T> task) {
throw new UnsupportedOperationException();
}
@Override
public <T> Future<T> submit(Runnable task, T result) {
throw new UnsupportedOperationException();
}
@Override
public Future<?> submit(Runnable task) {
throw new UnsupportedOperationException();
}
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
throw new UnsupportedOperationException();
}
Source
Frequently Asked Questions
What is the SpinExecutorService class?
SpinExecutorService is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/concurrent/BurstCostExecutorsBenchmark.java.
Where is SpinExecutorService defined?
SpinExecutorService is defined in microbench/src/main/java/io/netty/microbench/concurrent/BurstCostExecutorsBenchmark.java at line 59.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free