misk icon indicating copy to clipboard operation
misk copied to clipboard

RepeatedTaskQueue needs a fixedRateSchedule

Open mightyguava opened this issue 6 years ago • 4 comments
trafficstars

RepeatedTaskQueue is Misk's take on AbstractScheduledService, but it doesn't have feature parity. It should support fixedRateSchedule(), where tasks are scheduled at that interval regardless of how long tasks are run, so that we do not miss a task due to a previous iteration taking too long.

mightyguava avatar Mar 14 '19 20:03 mightyguava

@mightyguava should tasks be allowed to overlap? ex: fixedRate(1 second) but the task takes 3 seconds should they keep piling up?

jjestrel avatar Apr 04 '19 14:04 jjestrel

Yup, that's the request.

mightyguava avatar Apr 04 '19 14:04 mightyguava

If by “overlap” you mean execute concurrently, then no - that’s not how scheduleAtFxedRate works in java.util.concurrent (tasks in juc never execute concurrently) and doing so here would violate principle of least astonishment.

FWIW tasks have complete control over their execution schedule and can implement fixed rate schedules directly, so this is really a convenience method - we didn’t implement the convenience method because in practice fixed rate schedules tend to be uncommon and usually a bit dangerous.

mmihic avatar Apr 04 '19 15:04 mmihic

Agreed, what I meant was that the tasks would queue up, but they would not be executing concurrently.

mightyguava avatar Apr 04 '19 15:04 mightyguava