Struct HandlerTable
pub struct HandlerTable<const N: usize> { /* private fields */ }
Expand description
A lock-free table of event handlers.
It internally uses an array of AtomicUsize
to store the handlers.
Implementations§
§impl<const N: usize> HandlerTable<N>
impl<const N: usize> HandlerTable<N>
pub const fn new() -> HandlerTable<N>
pub const fn new() -> HandlerTable<N>
Creates a new handler table with all entries empty.
pub fn register_handler(&self, idx: usize, handler: fn()) -> bool
pub fn register_handler(&self, idx: usize, handler: fn()) -> bool
Registers a handler for the given index.
Returns true
if the registration succeeds, false
if the index is out
of bounds or the handler is already registered.
pub fn unregister_handler(&self, idx: usize) -> Option<fn()>
pub fn unregister_handler(&self, idx: usize) -> Option<fn()>
Unregisters the handler for the given index.
Returns the existing handler if it is registered, None
otherwise.
Trait Implementations§
§impl<const N: usize> Default for HandlerTable<N>
impl<const N: usize> Default for HandlerTable<N>
§fn default() -> HandlerTable<N>
fn default() -> HandlerTable<N>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<const N: usize> !Freeze for HandlerTable<N>
impl<const N: usize> RefUnwindSafe for HandlerTable<N>
impl<const N: usize> Send for HandlerTable<N>
impl<const N: usize> Sync for HandlerTable<N>
impl<const N: usize> Unpin for HandlerTable<N>
impl<const N: usize> UnwindSafe for HandlerTable<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more