Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Aug 30, 2019
1 parent 127311b commit 9fd203a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/libstd/sys/wasi/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ impl Thread {
type_: wasi::EVENTTYPE_CLOCK,
u: wasi::raw::__wasi_subscription_u { clock: clock },
}];
let mut out: [wasi::Event; 1] = [unsafe { mem::zeroed() }];
let n = unsafe { wasi::poll_oneoff(&in_, &mut out).unwrap() };
let wasi::Event { userdata, error, type_, .. } = out[0];
match (n, userdata, error) {
(1, CLOCK_ID, 0) if type_ == wasi::EVENTTYPE_CLOCK => {}
let (res, event) = unsafe {
let mut out: [wasi::Event; 1] = mem::zeroed();
let res = wasi::poll_oneoff(&in_, &mut out);
(res, out[0])
};
match (res, event) {
(Ok(1), wasi::Event {
userdata: CLOCK_ID,
error: 0,
type_: wasi::EVENTTYPE_CLOCK,
..
}) => {}
_ => panic!("thread::sleep(): unexpected result of poll_oneoff"),
}
}
Expand Down

0 comments on commit 9fd203a

Please sign in to comment.