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§
source§impl<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.
source§impl<S: MutEventSubscriber> EventManager<S>
impl<S: MutEventSubscriber> EventManager<S>
sourcepub fn remote_endpoint(&self) -> RemoteEndpoint<S>
Available on crate feature remote_endpoint
only.
pub fn remote_endpoint(&self) -> RemoteEndpoint<S>
remote_endpoint
only.Return a RemoteEndpoint
object, that allows interacting with the EventManager
from a
different thread. Using RemoteEndpoint::call_blocking
on the same thread the event loop
runs on leads to a deadlock.
Trait Implementations§
source§impl<T: Debug> Debug for EventManager<T>
impl<T: Debug> Debug for EventManager<T>
source§impl<T: MutEventSubscriber> SubscriberOps for EventManager<T>
impl<T: MutEventSubscriber> SubscriberOps for EventManager<T>
source§fn 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.
source§fn 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.
source§fn 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.
source§fn 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.