Skip to content

♻️ (minor) v6: Share one slot type across edge dispatcher sizes - #116

Merged
kammce merged 3 commits into
mainfrom
v6-shared-edge-interrupt-slot
Oct 23, 2026
Merged

kammce merged 3 commits into
mainfrom
v6-shared-edge-interrupt-slot

Conversation

@kammce

@kammce kammce commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

edge_triggered_interrupt_dispatcher<SlotCount> declared slot as a nested class, so each slot count produced its own slot type: dispatcher<2>::slot and dispatcher<7>::slot were separate classes, each with its own vtable and member functions.

This moves the slot out to namespace scope as hal::edge_triggered_interrupt_slot. Every dispatcher now uses that one type, and operator[] returns edge_triggered_interrupt_slot&. The slot's default constructor is private and the dispatcher is its friend, so only a dispatcher can create a slot or call dispatch(). Behavior is unchanged.

Code that spelled edge_triggered_interrupt_dispatcher<N>::slot must now write hal::edge_triggered_interrupt_slot. Code that uses auto& or hal::edge_triggered_interrupt& doesn't change.

Also:

  • The tests use static_cast<void>() instead of (void).
  • A compile check confirms user code can't construct a slot.
  • Two static_asserts check that dispatcher<2> and dispatcher<7> return the same slot type.

#111 makes the same change for can_interrupt_dispatcher (hal::can_interrupt_slot).

Move the nested slot out of edge_triggered_interrupt_dispatcher<N> into
hal::edge_triggered_interrupt_slot, so dispatchers of different sizes no
longer instantiate their own slot class and vtable.

Use static_cast<void>() instead of a C-style void cast in the tests.
Only a dispatcher creates slots, so user code cannot make one.

@kammce kammce left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kammce kammce left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@kammce
kammce merged commit 92260bd into main Oct 23, 2026
10 checks passed
@kammce
kammce deleted the v6-shared-edge-interrupt-slot branch October 23, 2026 14:01
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