HandlerList
struct · ferroui-system · v0.5.0
struct HandlerList<F: ?Sized>
A list of event handlers that tolerates being modified while it is being invoked: invocation works on a snapshot, and the snapshot is only copied when the list actually changes.
A list is one pointer wide. An object with a dozen events, almost all of which nobody subscribes to, pays that for each of them and nothing else (desktop-performance.md, section 9.40).
The tokens of every list come from one counter of the process: within a list, and across lists, a later subscription has a greater token, and a token is never given out twice. The typed and the untyped form of one event, which run their handlers in subscription order as the single event of the original, need nothing more than that.
Members
new
const fn new() -> Self
is_empty
fn is_empty(self: &Self) -> bool
len
fn len(self: &Self) -> usize
add
fn add(self: &Self, handler: Rc<F>) -> u64
Adds a handler and returns a token that removes it again.
remove
fn remove(self: &Self, token: u64) -> bool
Removes the handler registered under token.
snapshot
fn snapshot(self: &Self) -> HandlerSnapshot<F>
Returns the current handlers; later modifications do not affect it.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyDefault
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.