Struct wayland_client::backend::ReadEventsGuard
source · [−]pub struct ReadEventsGuard { /* private fields */ }
Expand description
Guard for synchronizing event reading across multiple threads
If multiple threads need to read events from the Wayland socket concurrently, it is necessary to synchronize their access. Failing to do so may cause some of the threads to not be notified of new events, and sleep much longer than appropriate.
To correctly synchronize access, this type should be used. The guard is created using
the try_new()
method. And the event reading is triggered by consuming
the guard using the read()
method.
If you plan to poll the Wayland socket for readiness, the file descriptor can be retrieved via
the connection_fd
method. Note that for the synchronization to
correctly occur, you must always create the ReadEventsGuard
before polling the socket.
Implementations
Create a new reading guard
This call will not block, but event callbacks may be invoked in the process of preparing the guard.
Access the Wayland socket FD for polling
Attempt to read events from the Wayland socket
If multiple threads have a live reading guard, this method will block until all of them
are either dropped or have their read()
method invoked, at which point on of the threads
will read events from the socket and invoke the callbacks for the received events. All
threads will then resume their execution.
This returns the number of dispatched events, or 0
if an other thread handled the dispatching.
If no events are available to read from the socket, this returns a WouldBlock
IO error.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for ReadEventsGuard
impl Send for ReadEventsGuard
impl Sync for ReadEventsGuard
impl Unpin for ReadEventsGuard
impl UnwindSafe for ReadEventsGuard
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more