We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c7657b7 commit f39ab75Copy full SHA for f39ab75
src/libstd/rt/io/timer.rs
@@ -17,6 +17,13 @@ use rt::local::Local;
17
18
pub struct Timer(~RtioTimerObject);
19
20
+/// Sleep the current task for `msecs` milliseconds.
21
+pub fn sleep(msecs: u64) {
22
+ let mut timer = Timer::new().expect("timer::sleep: could not create a Timer");
23
+
24
+ timer.sleep(msecs)
25
+}
26
27
impl Timer {
28
29
pub fn new() -> Option<Timer> {
@@ -52,4 +59,11 @@ mod test {
52
59
do timer.map_move |mut t| { t.sleep(1) };
53
60
}
54
61
62
63
+ #[test]
64
+ fn test_io_timer_sleep_standalone() {
65
+ do run_in_mt_newsched_task {
66
+ sleep(1)
67
+ }
68
55
69
0 commit comments