Struct message_io::events::EventReceiver
source · pub struct EventReceiver<E> { /* private fields */ }
Expand description
A generic and synchronized queue where the user can send and receive events.
See EventSender
to see how send events.
This entity can be used as an utility for the crate::network
module redirecting the
network events to process them later from here.
Implementations§
source§impl<E> EventReceiver<E>where
E: Send + 'static,
impl<E> EventReceiver<E>where
E: Send + 'static,
sourcepub fn sender(&self) -> &EventSender<E>
pub fn sender(&self) -> &EventSender<E>
Returns the internal sender reference to this queue. This reference can be safety cloned and shared to other threads in order to get several senders to the same queue.
sourcepub fn receive(&mut self) -> E
pub fn receive(&mut self) -> E
Blocks the current thread until an event is received by this queue.
sourcepub fn receive_timeout(&mut self, timeout: Duration) -> Option<E>
pub fn receive_timeout(&mut self, timeout: Duration) -> Option<E>
Blocks the current thread until an event is received by this queue or timeout is exceeded. If timeout is reached a None is returned, otherwise the event is returned.
sourcepub fn try_receive(&mut self) -> Option<E>
pub fn try_receive(&mut self) -> Option<E>
Attempts to receive an event without blocking. Returns Some(E) if an event was received by this queue, otherwise returns None.