pub fn run_delayed<F: 'static, I>(&self, dur: Duration, fun: F)
	where
		F: Send + FnOnce(Instant) -> I,
		I: Into<Option<TimerEvent>>,
	{
		let instant = Instant::now() + dur;
		let mut opt = Some(fun);

		self.tasks.lock().unwrap().push(Task {
			time: instant,
			func: Box::new(move |inst| {
				// This is a little bit hack, but since
				// it is impossible to call a Box<FnOnce(...) -> ...>
				// in stable rust without enabling yet another
				// nightly extension this will have to do instead.
				let fun =
					mem::replace(&mut opt, None).expect("Delayed task was executed more than once");

				fun(inst).into()
			}),
		});
	}
/// Runs the function after the
/// timeout has completed
Runs the function after the
timeout has completed
Runs the function after the timeout has completed
pub fn run_delayed<F: 'static, I>(&self, dur: Duration, fun: F)
	where
		F: Send + FnOnce(Instant) -> I,
		I: Into<Option<TimerEvent>>,
	{
		let instant = Instant::now() + dur;
		let mut opt = Some(fun);
		self.tasks.lock().unwrap().push(Task {
			time: instant,
			func: Box::new(move |inst| {
				// This is a little bit hack, but since
				// it is impossible to call a Box<FnOnce(...) -> ...>
				// in stable rust without enabling yet another
				// nightly extension this will have to do instead.
				let fun =
					mem::replace(&mut opt, None).expect("Delayed task was executed more than once");
				fun(inst).into()
			}),
		});
	}
pub fn run_delayed < F : ' static , I > ( & self , dur : Duration , fun : F ) where F : Send + FnOnce ( Instant ) -> I , I : Into < Option < TimerEvent > > , { let instant = Instant :: now ( ) + dur ; let mut opt = Some ( fun ) ; self . tasks . lock ( ) . unwrap ( ) . push ( Task { time : instant , func : Box :: new ( move | inst | { // This is a little bit hack, but since // it is impossible to call a Box<FnOnce(...) -> ...> // in stable rust without enabling yet another // nightly extension this will have to do instead. let fun = mem :: replace ( & mut opt , None ) . expect ( " " ) ; fun ( inst ) . into ( ) } ) , } ) ; }
Runs the function after the
timeout has completed
Runs the function after the timeout has completed
&self
dur
Duration
fun
F
&self
dur
Duration
fun
F