Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wasi crate for Core API #63676

Merged
merged 23 commits into from
Sep 6, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
simplify code
  • Loading branch information
newpavlov committed Aug 30, 2019
commit 9fd203a01e0fe6fb307809fdfdbfcd3bda350cfc
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