auto merge of #9191 : huonw/rust/are-you-tired, r=cmr
Allows `std::rt::io::timer::sleep(1000)` rather than `std::rt::io::timer::Timer::new().unwrap().sleep(1000)`.
This commit is contained in:
commit
5c4f65e6f5
@ -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> {
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user