refactor: extract periodic task loop into reusable run_periodic_tasks#761
Open
ok300 wants to merge 2 commits intopubky:feat/dx-events-by-userfrom
Open
refactor: extract periodic task loop into reusable run_periodic_tasks#761ok300 wants to merge 2 commits intopubky:feat/dx-events-by-userfrom
run_periodic_tasks#761ok300 wants to merge 2 commits intopubky:feat/dx-events-by-userfrom
Conversation
Set MissedTickBehavior::Skip on the interval timer in run_periodic_tasks so that if a task takes longer than its tick interval, missed ticks are dropped instead of queuing up a burst of back-to-back invocations. Added tests verifying that slow tasks don't accumulate queued ticks and that fast tasks still tick at the expected cadence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR simplifies and modularizes
NexusWatcher::startas follows:PeriodicTask::newPeriodicTaskis given as arg torun_periodic_tasksrun_periodic_tasksspawns the tasks each in their own thread, registers the shutdown signal + the intervaltick()+ the cancellation signalThe cancellation signal is used by
run_periodic_tasksto detect when a task has panicked. It then triggers a graceful shutdown from all other parallel running tasks.This PR also uses the
MissedTickBehavior::Skipfor therun_periodic_tasksthreads.This PR is an alternative implementation for #757 and #760.