public abstract class AbstractScheduledEventExecutor extends AbstractEventExecutor
EventExecutors that want to support scheduling.AbstractEventExecutor.LazyRunnable| Modifier | Constructor and Description |
|---|---|
protected |
AbstractScheduledEventExecutor() |
protected |
AbstractScheduledEventExecutor(EventExecutorGroup parent) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
afterScheduledTaskSubmitted(long deadlineNanos)
|
protected boolean |
beforeScheduledTaskSubmitted(long deadlineNanos)
Called from arbitrary non-
EventExecutor threads prior to scheduled task submission. |
protected void |
cancelScheduledTasks()
Cancel all scheduled tasks.
|
protected static long |
deadlineToDelayNanos(long deadlineNanos)
Given an arbitrary deadline
deadlineNanos, calculate the number of nano seconds from now
deadlineNanos would expire. |
protected long |
getCurrentTimeNanos()
Get the current time in nanoseconds by this executor's clock.
|
protected boolean |
hasScheduledTasks()
Returns
true if a scheduled task is ready for processing. |
protected static long |
initialNanoTime()
The initial value used for delay and computations based upon a monatomic time source.
|
protected static long |
nanoTime()
Deprecated.
Use the non-static
getCurrentTimeNanos() instead. |
protected long |
nextScheduledTaskDeadlineNanos()
Return the deadline (in nanoseconds) when the next scheduled task is ready to be run or
-1
if no task is scheduled. |
protected long |
nextScheduledTaskNano()
Return the nanoseconds until the next scheduled task is ready to be run or
-1 if no task is scheduled. |
protected Runnable |
pollScheduledTask() |
protected Runnable |
pollScheduledTask(long nanoTime)
Return the
Runnable which is ready to be executed with the given nanoTime. |
<V> ScheduledFuture<V> |
schedule(Callable<V> callable,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
schedule(Runnable command,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit) |
protected void |
validateScheduled(long amount,
TimeUnit unit)
Deprecated.
will be removed in the future.
|
inEventLoop, iterator, lazyExecute, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, newTaskFor, newTaskFor, next, parent, runTask, safeExecute, shutdown, shutdownGracefully, shutdownNow, submit, submit, submitinvokeAll, invokeAll, invokeAny, invokeAnyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinEventLoopisShuttingDown, shutdownGracefully, terminationFutureawaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminatedforEach, spliteratorprotected AbstractScheduledEventExecutor()
protected AbstractScheduledEventExecutor(EventExecutorGroup parent)
protected long getCurrentTimeNanos()
System.nanoTime()
for two reasons:
nanoTime@Deprecated protected static long nanoTime()
getCurrentTimeNanos() instead.protected static long deadlineToDelayNanos(long deadlineNanos)
deadlineNanos, calculate the number of nano seconds from now
deadlineNanos would expire.deadlineNanos - An arbitrary deadline in nano seconds.deadlineNanos would expire.protected static long initialNanoTime()
protected void cancelScheduledTasks()
AbstractEventExecutor.inEventLoop() is true.protected final Runnable pollScheduledTask()
pollScheduledTask(long)protected final Runnable pollScheduledTask(long nanoTime)
Runnable which is ready to be executed with the given nanoTime.
You should use getCurrentTimeNanos() to retrieve the correct nanoTime.protected final long nextScheduledTaskNano()
-1 if no task is scheduled.protected final long nextScheduledTaskDeadlineNanos()
-1
if no task is scheduled.protected final boolean hasScheduledTasks()
true if a scheduled task is ready for processing.public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
schedule in interface EventExecutorGroupschedule in interface ScheduledExecutorServiceschedule in class AbstractEventExecutorpublic <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
schedule in interface EventExecutorGroupschedule in interface ScheduledExecutorServiceschedule in class AbstractEventExecutorpublic ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)
scheduleAtFixedRate in interface EventExecutorGroupscheduleAtFixedRate in interface ScheduledExecutorServicescheduleAtFixedRate in class AbstractEventExecutorpublic ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit)
scheduleWithFixedDelay in interface EventExecutorGroupscheduleWithFixedDelay in interface ScheduledExecutorServicescheduleWithFixedDelay in class AbstractEventExecutor@Deprecated protected void validateScheduled(long amount, TimeUnit unit)
protected boolean beforeScheduledTaskSubmitted(long deadlineNanos)
EventExecutor threads prior to scheduled task submission.
Returns true if the EventExecutor thread should be woken immediately to
process the scheduled task (if not already awake).
If false is returned, afterScheduledTaskSubmitted(long) will be called with
the same value after the scheduled task is enqueued, providing another opportunity
to wake the EventExecutor thread if required.
deadlineNanos - deadline of the to-be-scheduled task
relative to getCurrentTimeNanos()true if the EventExecutor thread should be woken, false otherwiseprotected boolean afterScheduledTaskSubmitted(long deadlineNanos)
beforeScheduledTaskSubmitted(long). Called only after that method returns false.deadlineNanos - relative to getCurrentTimeNanos()true if the EventExecutor thread should be woken, false otherwiseCopyright © 2008–2025 The Netty Project. All rights reserved.