Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recurring schedules? #8

Open
benlesh opened this issue Feb 23, 2020 · 2 comments
Open

Recurring schedules? #8

benlesh opened this issue Feb 23, 2020 · 2 comments
Labels
enhancement New feature or request postTask API Related to the postTask API

Comments

@benlesh
Copy link

benlesh commented Feb 23, 2020

I didn't see anything about how this API will allow the scheduling of recurring tasks, like an interval, which has a different behavior than recursively scheduling one task at a time could ever provide. Did I just miss it? Also how does prioritization fit in there?

@shaseley
Copy link
Collaborator

(Apologies, this fell off my radar.)

The API does support an option for delayed tasks, but we haven't added an option for recurring tasks yet (i.e. we essentially have prioritized setTimeout but not setInterval). Being able to post (prioritized) delayed tasks is something that came up in designing this API, but intervals not so much (so far). But, I'd imagine for consistency we'd include this as well, maybe something like:

scheduler.postTask(foo, {delay: 1000, repeating: true})

?

As far as how prioritization fits in: the tasks are queued when the delay expires (similar to how setTimeout works). So the delta between a task's delay expiring and when it starts depends on thread congestion, and that delta should be a bit smaller on average for delayed user-blocking tasks (they'd run before currently queued user-visible and background tasks).

@shaseley shaseley added enhancement New feature or request postTask API Related to the postTask API labels Jun 30, 2021
@esprehn
Copy link

esprehn commented Sep 20, 2024

This would be nice to add, doing the alignment math yourself is not something I think most folks would figure out:

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/timer.cc;l=155;drc=48ee6c4ee320c1bcc4f7d01d5c293e6d41ecf648;bpv=0;bpt=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request postTask API Related to the postTask API
Projects
None yet
Development

No branches or pull requests

3 participants