SingleThreadEventExecutor Class — netty Architecture
Architecture documentation for the SingleThreadEventExecutor class in SingleThreadEventExecutor.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c9189467_acbc_07ea_3a8c_fecfe22ec122["SingleThreadEventExecutor"] 0f39a674_7a79_67d3_7730_add75b8e1c7e["SingleThreadEventExecutor.java"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|defined in| 0f39a674_7a79_67d3_7730_add75b8e1c7e b9e67f58_3c41_ba0b_643c_0eda74b7662a["SingleThreadEventExecutor()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| b9e67f58_3c41_ba0b_643c_0eda74b7662a 759ffc07_ff2c_bd5d_a263_7521f04763da["newTaskQueue()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| 759ffc07_ff2c_bd5d_a263_7521f04763da b549f734_13b1_3abe_4f6d_8ab5a97277cf["interruptThread()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| b549f734_13b1_3abe_4f6d_8ab5a97277cf 8846f570_8032_89c9_e9e7_f552f8890802["Runnable()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| 8846f570_8032_89c9_e9e7_f552f8890802 736e6f77_4f80_844d_7e6b_1a1ec1cd6dc6["fetchFromScheduledTaskQueue()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| 736e6f77_4f80_844d_7e6b_1a1ec1cd6dc6 ca91acb1_82cd_2370_4ca6_61b2353753d6["executeExpiredScheduledTasks()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| ca91acb1_82cd_2370_4ca6_61b2353753d6 b7cffda2_e81d_782d_d050_74585639f731["hasTasks()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| b7cffda2_e81d_782d_d050_74585639f731 a817c03d_8c42_2c05_63fd_2c681eae01ea["pendingTasks()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| a817c03d_8c42_2c05_63fd_2c681eae01ea 2db76fa7_bcbb_0b02_d658_d457f2ba303d["addTask()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| 2db76fa7_bcbb_0b02_d658_d457f2ba303d 758c3e40_fd6c_146c_1ccc_29403507b85d["offerTask()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| 758c3e40_fd6c_146c_1ccc_29403507b85d 80bb773b_c9d4_0542_be2a_9efedef780ee["removeTask()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| 80bb773b_c9d4_0542_be2a_9efedef780ee aae2a1cf_9734_69c3_1254_17f62df7beab["runAllTasks()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| aae2a1cf_9734_69c3_1254_17f62df7beab 5a39e93d_3c59_adfe_8e2c_fcd0d6bdeea5["runScheduledAndExecutorTasks()"] c9189467_acbc_07ea_3a8c_fecfe22ec122 -->|method| 5a39e93d_3c59_adfe_8e2c_fcd0d6bdeea5
Relationship Graph
Source Code
common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java lines 55–1371
public abstract class SingleThreadEventExecutor extends AbstractScheduledEventExecutor implements OrderedEventExecutor {
static final int DEFAULT_MAX_PENDING_EXECUTOR_TASKS = Math.max(16,
SystemPropertyUtil.getInt("io.netty.eventexecutor.maxPendingTasks", Integer.MAX_VALUE));
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(SingleThreadEventExecutor.class);
private static final int ST_NOT_STARTED = 1;
private static final int ST_SUSPENDING = 2;
private static final int ST_SUSPENDED = 3;
private static final int ST_STARTED = 4;
private static final int ST_SHUTTING_DOWN = 5;
private static final int ST_SHUTDOWN = 6;
private static final int ST_TERMINATED = 7;
private static final Runnable NOOP_TASK = new Runnable() {
@Override
public void run() {
// Do nothing.
}
};
private static final AtomicIntegerFieldUpdater<SingleThreadEventExecutor> STATE_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(SingleThreadEventExecutor.class, "state");
private static final AtomicReferenceFieldUpdater<SingleThreadEventExecutor, ThreadProperties> PROPERTIES_UPDATER =
AtomicReferenceFieldUpdater.newUpdater(
SingleThreadEventExecutor.class, ThreadProperties.class, "threadProperties");
private static final AtomicLongFieldUpdater<SingleThreadEventExecutor> ACCUMULATED_ACTIVE_TIME_NANOS_UPDATER =
AtomicLongFieldUpdater.newUpdater(SingleThreadEventExecutor.class, "accumulatedActiveTimeNanos");
private static final AtomicIntegerFieldUpdater<SingleThreadEventExecutor> CONSECUTIVE_IDLE_CYCLES_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(SingleThreadEventExecutor.class, "consecutiveIdleCycles");
private static final AtomicIntegerFieldUpdater<SingleThreadEventExecutor> CONSECUTIVE_BUSY_CYCLES_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(SingleThreadEventExecutor.class, "consecutiveBusyCycles");
private final Queue<Runnable> taskQueue;
private volatile Thread thread;
@SuppressWarnings("unused")
private volatile ThreadProperties threadProperties;
private final Executor executor;
private volatile boolean interrupted;
private final Lock processingLock = new ReentrantLock();
private final CountDownLatch threadLock = new CountDownLatch(1);
private final Set<Runnable> shutdownHooks = new LinkedHashSet<Runnable>();
private final boolean addTaskWakesUp;
private final int maxPendingTasks;
private final RejectedExecutionHandler rejectedExecutionHandler;
private final boolean supportSuspension;
// A running total of nanoseconds this executor has spent in an "active" state.
private volatile long accumulatedActiveTimeNanos;
// Timestamp of the last recorded activity (tasks + I/O).
private volatile long lastActivityTimeNanos;
/**
* Tracks the number of consecutive monitor cycles this executor's
* utilization has been below the scale-down threshold.
*/
private volatile int consecutiveIdleCycles;
/**
* Tracks the number of consecutive monitor cycles this executor's
* utilization has been above the scale-up threshold.
*/
private volatile int consecutiveBusyCycles;
private long lastExecutionTime;
@SuppressWarnings({ "FieldMayBeFinal", "unused" })
private volatile int state = ST_NOT_STARTED;
private volatile long gracefulShutdownQuietPeriod;
private volatile long gracefulShutdownTimeout;
private long gracefulShutdownStartTime;
private final Promise<?> terminationFuture = new DefaultPromise<Void>(GlobalEventExecutor.INSTANCE);
/**
* Create a new instance
*
* @param parent the {@link EventExecutorGroup} which is the parent of this instance and belongs to it
* @param threadFactory the {@link ThreadFactory} which will be used for the used {@link Thread}
Source
Frequently Asked Questions
What is the SingleThreadEventExecutor class?
SingleThreadEventExecutor is a class in the netty codebase, defined in common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java.
Where is SingleThreadEventExecutor defined?
SingleThreadEventExecutor is defined in common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java at line 55.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free