scheduleWithFixedDelay vs scheduleAtFixedRate, #26910
* previous `schedule` method is trying to maintain a fixed average frequency over time, but that can result in undesired bursts of scheduled tasks after a long GC or if the JVM process has been suspended, same with all other periodic scheduled message sending via various Timer APIs * most of the time "fixed delay" is more desirable * we can't just change because it's too big behavioral change and some might depend on previous behavior * deprecate the old `schedule` and introduce new `scheduleWithFixedDelay` and `scheduleAtFixedRate`, when fixing the deprecation warning users should make a concious decision of which behavior to use (scheduleWithFixedDelay in most cases) * Streams * SchedulerSpec * test both fixed delay and fixed rate * TimerSpec * FSM and PersistentFSM * mima * runnable as second parameter list, also in typed.Scheduler * IllegalStateException vs SchedulerException * deprecated annotations * api and reference docs, all places * migration guide
This commit is contained in:
parent
72cfc2485e
commit
10d32fceb9
99 changed files with 2285 additions and 909 deletions
|
|
@ -417,11 +417,23 @@ private final case class SavedIslandData(
|
|||
|
||||
override lazy val executionContext: ExecutionContextExecutor = dispatchers.lookup(settings.dispatcher)
|
||||
|
||||
override def scheduleWithFixedDelay(
|
||||
initialDelay: FiniteDuration,
|
||||
delay: FiniteDuration,
|
||||
task: Runnable): Cancellable =
|
||||
system.scheduler.scheduleWithFixedDelay(initialDelay, delay)(task)(executionContext)
|
||||
|
||||
override def scheduleAtFixedRate(
|
||||
initialDelay: FiniteDuration,
|
||||
interval: FiniteDuration,
|
||||
task: Runnable): Cancellable =
|
||||
system.scheduler.scheduleAtFixedRate(initialDelay, interval)(task)(executionContext)
|
||||
|
||||
override def schedulePeriodically(
|
||||
initialDelay: FiniteDuration,
|
||||
interval: FiniteDuration,
|
||||
task: Runnable): Cancellable =
|
||||
system.scheduler.schedule(initialDelay, interval, task)(executionContext)
|
||||
system.scheduler.scheduleAtFixedRate(initialDelay, interval)(task)(executionContext)
|
||||
|
||||
override def scheduleOnce(delay: FiniteDuration, task: Runnable): Cancellable =
|
||||
system.scheduler.scheduleOnce(delay, task)(executionContext)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue