Struct dbs_utils::epoll_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> EventManager<S> where
S: MutEventSubscriber,
impl<S> EventManager<S> where
S: MutEventSubscriber,
sourcepub fn new() -> Result<EventManager<S>, Error>
pub fn new() -> Result<EventManager<S>, Error>
Create a new EventManger object.
sourcepub fn new_with_capacity(
ready_events_capacity: usize
) -> Result<EventManager<S>, Error>
pub fn new_with_capacity(
ready_events_capacity: usize
) -> Result<EventManager<S>, Error>
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, Error>
pub fn run(&mut self) -> Result<usize, Error>
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, Error>
pub fn run_with_timeout(&mut self, milliseconds: i32) -> Result<usize, Error>
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.
sourceimpl<S> EventManager<S> where
S: MutEventSubscriber,
impl<S> EventManager<S> where
S: MutEventSubscriber,
sourcepub fn remote_endpoint(&self) -> RemoteEndpoint<S>
pub fn remote_endpoint(&self) -> RemoteEndpoint<S>
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
sourceimpl<T> SubscriberOps for EventManager<T> where
T: MutEventSubscriber,
impl<T> SubscriberOps for EventManager<T> where
T: MutEventSubscriber,
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, Error>
fn remove_subscriber(&mut self, subscriber_id: SubscriberId) -> Result<T, Error>
Unregisters and returns the subscriber associated with the provided ID.
sourcefn subscriber_mut(
&mut self,
subscriber_id: SubscriberId
) -> Result<&mut T, Error>
fn subscriber_mut(
&mut self,
subscriber_id: SubscriberId
) -> Result<&mut T, Error>
Return a mutable reference to the subscriber associated with the provided id.
sourcefn event_ops(
&mut self,
subscriber_id: SubscriberId
) -> Result<EventOps<'_>, Error>
fn event_ops(
&mut self,
subscriber_id: SubscriberId
) -> Result<EventOps<'_>, Error>
Returns a EventOps object for the subscriber associated with the provided ID.
type Subscriber = T
type Subscriber = T
Subscriber type for which the operations apply.
Auto Trait Implementations
impl<T> !RefUnwindSafe for EventManager<T>
impl<T> Send for EventManager<T> where
T: Send,
impl<T> !Sync for EventManager<T>
impl<T> Unpin for EventManager<T> where
T: Unpin,
impl<T> !UnwindSafe for EventManager<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more