Repository navigation
♻️ (minor) v6: Share one slot type across edge dispatcher sizes - #116
Merged
Merged
Conversation
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.
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.
edge_triggered_interrupt_dispatcher<SlotCount>declaredslotas a nested class, so each slot count produced its own slot type:dispatcher<2>::slotanddispatcher<7>::slotwere 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, andoperator[]returnsedge_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 calldispatch(). Behavior is unchanged.Code that spelled
edge_triggered_interrupt_dispatcher<N>::slotmust now writehal::edge_triggered_interrupt_slot. Code that usesauto&orhal::edge_triggered_interrupt&doesn't change.Also:
static_cast<void>()instead of(void).static_asserts check thatdispatcher<2>anddispatcher<7>return the same slot type.#111 makes the same change for
can_interrupt_dispatcher(hal::can_interrupt_slot).