Struct asynchronous::EventLoopHandler
[−]
[src]
pub struct EventLoopHandler<Ev> { // some fields omitted }
Event Loop wrapper that can be cloned to pass through threads
Methods
impl<Ev> EventLoopHandler<Ev> where Ev: Send + 'static
fn emit(&self, event: Ev) -> Result<(), Ev>
Triggers an event "Ev" once. Returns the same event if the event loop is not active.
fn emit_until<F>(&self, f: F) where F: Send + 'static + Fn() -> Emit<Ev>
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"]); });
fn is_active(&self) -> bool
Returns true if the event loop is running
fn finish(&self)
Finishes the event loop immediately.
fn finish_in_ms(&self, duration_ms: u32)
Finishes the event loop in N milliseconds