pub struct EventLoopHandler<Ev> { /* private fields */ }
Expand description
Event Loop wrapper that can be cloned to pass through threads
Implementations§
Source§impl<Ev> EventLoopHandler<Ev>where
Ev: Send + 'static,
impl<Ev> EventLoopHandler<Ev>where
Ev: Send + 'static,
Sourcepub fn emit(&self, event: Ev) -> Result<(), Ev>
pub fn emit(&self, event: Ev) -> Result<(), Ev>
Triggers an event “Ev” once. Returns the same event if the event loop is not active.
Sourcepub fn emit_until<F>(&self, f: F)
pub fn emit_until<F>(&self, f: F)
Triggers an event “Ev” until the return of the “clousure” is None
use asynchronous::{EventLoop, Emit};
let el = EventLoop::new();
let x = std::sync::Arc::new(std::sync::Mutex::new(0));
el.emit_until(move || {
let mut lock_x = x.lock().unwrap(); *lock_x += 1;
if *lock_x <= 3 { Emit::Event("Event Test") } else { Emit::Stop }
});
// Do something here
el.finish_in_ms(100).to_promise().finally_sync(|res| { // res: Result<Vec<Ev>,()>
assert_eq!(res.unwrap(), vec!["Event Test", "Event Test", "Event Test"]);
});
Sourcepub fn finish_in_ms(&self, duration_ms: u32)
pub fn finish_in_ms(&self, duration_ms: u32)
Finishes the event loop in N milliseconds
Trait Implementations§
Source§impl<Ev> Clone for EventLoopHandler<Ev>
impl<Ev> Clone for EventLoopHandler<Ev>
Source§fn clone(&self) -> EventLoopHandler<Ev>
fn clone(&self) -> EventLoopHandler<Ev>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<Ev> Freeze for EventLoopHandler<Ev>
impl<Ev> RefUnwindSafe for EventLoopHandler<Ev>
impl<Ev> Send for EventLoopHandler<Ev>where
Ev: Send,
impl<Ev> Sync for EventLoopHandler<Ev>where
Ev: Send,
impl<Ev> Unpin for EventLoopHandler<Ev>
impl<Ev> UnwindSafe for EventLoopHandler<Ev>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more