@Internal public class SystemProcessingTimeService extends Object implements TimerService
TimerService which assigns as current processing time the result of calling
System.currentTimeMillis() and registers timers using a ScheduledThreadPoolExecutor.| 限定符和类型 | 方法和说明 |
|---|---|
void |
awaitPendingAfterQuiesce()
This method can be used after calling
TimerService.quiesce(), and awaits the completion
of currently executing timers. |
protected void |
finalize() |
long |
getCurrentProcessingTime()
Returns the current processing time.
|
boolean |
isTerminated()
Returns true if the service has been shut down, false otherwise.
|
void |
quiesce()
This method puts the service into a state where it does not register new timers, but
returns for each call to
ProcessingTimeService.registerTimer(long, ProcessingTimeCallback) only a "mock" future. |
ScheduledFuture<?> |
registerTimer(long timestamp,
ProcessingTimeCallback callback)
Registers a task to be executed no sooner than time
timestamp, but without strong
guarantees of order. |
ScheduledFuture<?> |
scheduleAtFixedRate(ProcessingTimeCallback callback,
long initialDelay,
long period)
Registers a task to be executed repeatedly at a fixed rate.
|
void |
shutdownService()
Shuts down and clean up the timer service provider hard and immediately.
|
boolean |
shutdownServiceUninterruptible(long timeoutMs)
Shuts down and clean up the timer service provider hard and immediately.
|
public long getCurrentProcessingTime()
ProcessingTimeServicepublic ScheduledFuture<?> registerTimer(long timestamp, ProcessingTimeCallback callback)
timestamp, but without strong
guarantees of order.registerTimer 在接口中 ProcessingTimeServicetimestamp - Time when the task is to be enabled (in processing time)callback - The task to be executedpublic ScheduledFuture<?> scheduleAtFixedRate(ProcessingTimeCallback callback, long initialDelay, long period)
ProcessingTimeServicescheduleAtFixedRate 在接口中 ProcessingTimeServicecallback - to be executed after the initial delay and then after each periodinitialDelay - initial delay to start executing callbackperiod - after the initial delay after which the callback is executedpublic boolean isTerminated()
TimerServiceisTerminated 在接口中 TimerServicepublic void quiesce()
throws InterruptedException
TimerServiceProcessingTimeService.registerTimer(long, ProcessingTimeCallback) only a "mock" future.
Furthermore, the method clears all not yet started timers.
This method can be used to cleanly shut down the timer service. The using components will not notice that the service is shut down (as for example via exceptions when registering a new timer), but the service will simply not fire any timer any more.
quiesce 在接口中 TimerServiceInterruptedExceptionpublic void awaitPendingAfterQuiesce()
throws InterruptedException
TimerServiceTimerService.quiesce(), and awaits the completion
of currently executing timers.awaitPendingAfterQuiesce 在接口中 TimerServiceInterruptedExceptionpublic void shutdownService()
TimerServiceProcessingTimeService.registerTimer(long, ProcessingTimeCallback)
will result in a hard exception.shutdownService 在接口中 TimerServicepublic boolean shutdownServiceUninterruptible(long timeoutMs)
TimerServiceProcessingTimeService.registerTimer(long, ProcessingTimeCallback)
will result in a hard exception. This call cannot be interrupted and will block until the shutdown is completed
or the timeout is exceeded.shutdownServiceUninterruptible 在接口中 TimerServicetimeoutMs - timeout for blocking on the service shutdown in milliseconds.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.