diff --git a/src/libstd/rt/io/timer.rs b/src/libstd/rt/io/timer.rs index 6754511b03811..53e4c4051e1c3 100644 --- a/src/libstd/rt/io/timer.rs +++ b/src/libstd/rt/io/timer.rs @@ -17,6 +17,13 @@ use rt::local::Local; pub struct Timer(~RtioTimerObject); +/// Sleep the current task for `msecs` milliseconds. +pub fn sleep(msecs: u64) { + let mut timer = Timer::new().expect("timer::sleep: could not create a Timer"); + + timer.sleep(msecs) +} + impl Timer { pub fn new() -> Option { @@ -52,4 +59,11 @@ mod test { do timer.map_move |mut t| { t.sleep(1) }; } } + + #[test] + fn test_io_timer_sleep_standalone() { + do run_in_mt_newsched_task { + sleep(1) + } + } }