Struct event_manager::EventManager
source · pub struct EventManager<T> { /* private fields */ }Expand description
Allows event subscribers to be registered, connected to the event loop, and later removed.
Implementations
sourceimpl<S: MutEventSubscriber> EventManager<S>
impl<S: MutEventSubscriber> EventManager<S>
sourcepub fn new_with_capacity(ready_events_capacity: usize) -> Result<Self>
pub fn new_with_capacity(ready_events_capacity: usize) -> Result<Self>
Creates a new EventManger object with specified event capacity.
Arguments
ready_events_capacity: maximum number of ready events to be processed a singlerun. The maximum value of this parameter isEventManager::MAX_READY_EVENTS_CAPACITY.
sourcepub fn run(&mut self) -> Result<usize>
pub fn run(&mut self) -> Result<usize>
Run the event loop blocking until events are triggered or an error is returned. Calls subscriber.process() for each event.
On success, it returns number of dispatched events or 0 when interrupted by a signal.
sourcepub fn run_with_timeout(&mut self, milliseconds: i32) -> Result<usize>
pub fn run_with_timeout(&mut self, milliseconds: i32) -> Result<usize>
Wait for events for a maximum timeout of miliseconds or until an error is returned.
Calls subscriber.process() for each event.
On success, it returns number of dispatched events or 0 when interrupted by a signal.
Trait Implementations
sourceimpl<T: MutEventSubscriber> SubscriberOps for EventManager<T>
impl<T: MutEventSubscriber> SubscriberOps for EventManager<T>
sourcefn add_subscriber(&mut self, subscriber: T) -> SubscriberId
fn add_subscriber(&mut self, subscriber: T) -> SubscriberId
Register a subscriber with the event event_manager and returns the associated ID.
sourcefn remove_subscriber(&mut self, subscriber_id: SubscriberId) -> Result<T>
fn remove_subscriber(&mut self, subscriber_id: SubscriberId) -> Result<T>
Unregisters and returns the subscriber associated with the provided ID.
sourcefn subscriber_mut(&mut self, subscriber_id: SubscriberId) -> Result<&mut T>
fn subscriber_mut(&mut self, subscriber_id: SubscriberId) -> Result<&mut T>
Return a mutable reference to the subscriber associated with the provided id.
sourcefn event_ops(&mut self, subscriber_id: SubscriberId) -> Result<EventOps<'_>>
fn event_ops(&mut self, subscriber_id: SubscriberId) -> Result<EventOps<'_>>
Returns a EventOps object for the subscriber associated with the provided ID.