pub struct EventLoop<'l, Data> { /* private fields */ }
Expand description
An event loop
This loop can host several event sources, that can be dynamically added or removed.
Implementations§
Source§impl<'l, Data> EventLoop<'l, Data>
impl<'l, Data> EventLoop<'l, Data>
Sourcepub fn try_new() -> Result<EventLoop<'l, Data>, Error>
pub fn try_new() -> Result<EventLoop<'l, Data>, Error>
Create a new event loop
Fails if the initialization of the polling system failed.
Sourcepub fn handle(&self) -> LoopHandle<'l, Data>
pub fn handle(&self) -> LoopHandle<'l, Data>
Retrieve a loop handle
Sourcepub fn dispatch<D>(&mut self, timeout: D, data: &mut Data) -> Result<(), Error>
pub fn dispatch<D>(&mut self, timeout: D, data: &mut Data) -> Result<(), Error>
Dispatch pending events to their callbacks
If some sources have events available, their callbacks will be immediatly called.
Otherwise this will wait until an event is receive or the provided timeout
is reached. If timeout
is None
, it will wait without a duration limit.
Once pending events have been processed or the timeout is reached, all pending idle callbacks will be fired before this method returns.
Sourcepub fn get_signal(&self) -> LoopSignal
pub fn get_signal(&self) -> LoopSignal
Get a signal to stop this event loop from running
To be used in conjunction with the run()
method.
Sourcepub fn run<F, D>(
&mut self,
timeout: D,
data: &mut Data,
cb: F,
) -> Result<(), Error>
pub fn run<F, D>( &mut self, timeout: D, data: &mut Data, cb: F, ) -> Result<(), Error>
Run this event loop
This will repeatedly try to dispatch events (see the dispatch()
method) on
this event loop, waiting at most timeout
every time.
Between each dispatch wait, your provided callback will be called.
You can use the get_signal()
method to retrieve a way to stop or wakeup
the event loop from anywhere.
Trait Implementations§
Auto Trait Implementations§
impl<'l, Data> Freeze for EventLoop<'l, Data>
impl<'l, Data> !RefUnwindSafe for EventLoop<'l, Data>
impl<'l, Data> !Send for EventLoop<'l, Data>
impl<'l, Data> !Sync for EventLoop<'l, Data>
impl<'l, Data> Unpin for EventLoop<'l, Data>
impl<'l, Data> !UnwindSafe for EventLoop<'l, Data>
Blanket Implementations§
Source§impl<T> AsSource for Twhere
T: AsFd,
impl<T> AsSource for Twhere
T: AsFd,
Source§fn source(&self) -> BorrowedFd<'_>
fn source(&self) -> BorrowedFd<'_>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more