RFC: Next scheduler API #7323
benlesh
started this conversation in
Ideas / Feature request
Replies: 1 comment
-
I like the idea of streamlining schedulers. I assume |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Our current scheduler API is quite complicated, and we want to redesign them to be simpler and make it easier for general users to implement their own schedulers.
Issues with the current scheduler architecture:
this
context in thework
parameter forScheduler#schedule
to reschedule the same action makes it harder to implement custom schedulers.setInterval
to schedule both one time work or repeated work adds a lot of complexity to our architecture, and has created more than a few hard to fix bugs. It also required an abstraction that leaked into every other scheduler implementation.Proposed API
As a strawman, this is the API I'm proposing. The only thing some folks might find odd is that you must pass in the
Subscription
that owns the scheduled work. We're passing it in ahead of time because some schedulers might schedule synchronously and in those cases we need the cancellation mechanism ahead of time.So an example "asyncScheduler" re-implementation with this API would look like so:
Rollout Plan
What I'd like to do is support both the current schedulers and a new type of scheduler throughout the library. So anywhere a scheduler can be passed, you can either pass an old one or a new one. That is, at least for the duration of version 8. During that time, all current schedulers will be deprecated, and users will be advised to use the newer schedulers.
Beta Was this translation helpful? Give feedback.
All reactions