Debian Codegraph @

third_party/rust/wio/src/sleep.rs

raw
1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 use {k32, w};
7
8 pub fn sleep(ms: u32) {
9 unsafe { k32::Sleep(ms) }
10 }
11 #[derive(Debug, Eq, PartialEq)]
12 pub enum WakeReason {
13 TimedOut,
14 CallbacksFired,
15 }
16 pub fn sleep_alertable(ms: u32) -> WakeReason {
17 let ret = unsafe { k32::SleepEx(ms, w::TRUE) };
18 match ret {
19 0 => WakeReason::TimedOut,
20 w::WAIT_IO_COMPLETION => WakeReason::CallbacksFired,
21 _ => unreachable!("SleepEx returned weird value of {:?}", ret),
22 }
23 }