Skip to content

♻️ Decouple context from virtual callback API via unblock_listener#80

Open
kammce wants to merge 2 commits intomainfrom
unblock-notification-injection
Open

♻️ Decouple context from virtual callback API via unblock_listener#80
kammce wants to merge 2 commits intomainfrom
unblock-notification-injection

Conversation

@kammce
Copy link
Member

@kammce kammce commented Mar 15, 2026

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

@kammce kammce force-pushed the unblock-notification-injection branch 2 times, most recently from 830f50e to a8d8b38 Compare March 15, 2026 22:43
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
@kammce kammce force-pushed the unblock-notification-injection branch from a8d8b38 to 10df548 Compare March 15, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant