♻️ Decouple context from virtual callback API via unblock_listener#80
Open
♻️ Decouple context from virtual callback API via unblock_listener#80
Conversation
830f50e to
a8d8b38
Compare
Separate the unblock notification mechanism from the context class into a dedicated `unblock_listener` interface. This eliminates the need for virtual function on context itself, allowing each context to be a simple, concrete object. The callback pattern is now only used for the unblock event—the only notification that must happen asynchronously (in ISRs or other threads). The scheduler can directly inspect context state to determine readiness and sleep duration without callbacks. Changes: - Extract unblock notification into `unblock_listener` interface - Remove virtual methods from context class - Update sleep_duration to use microseconds (u32) instead of nanoseconds to save 4 bytes, reduce the timing requirements on the scheduler, and to provide a more realistic delay range for most systems. - Simplify context state inspection for scheduler decision-making - Add `on_unblock()` listener registration/clearing on context - Update tests to use new listener-based design
a8d8b38 to
10df548
Compare
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.
Separate the unblock notification mechanism from the context class into a dedicated
unblock_listenerinterface. This eliminates the need for virtual function on context itself, allowing each context to be a simple, concrete object.The callback pattern is now only used for the unblock event—the only notification that must happen asynchronously (in ISRs or other threads). The scheduler can directly inspect context state to determine readiness and sleep duration without callbacks.
Changes:
unblock_listenerinterfaceon_unblock()listener registration/clearing on context