Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libstd/rt/io/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Timer> {
Expand Down Expand Up @@ -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)
}
}
}