-
Notifications
You must be signed in to change notification settings - Fork 45
Add blocking-based poll_oneoff to support clock_nanosleep
#88
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
Conversation
598a66d to
ccc5dce
Compare
| : getNow() + timeout; | ||
| while (endTime > getNow()) { | ||
| // block until the timeout is reached | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an ideal solution as this will block user interaction if it runs on the main thread and unnecessarily uses the cpu which especially on mobile devices is bad, but I guess there isn't really a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, JSPI could be a mitigation but I think it's too early to use it here
|
Sorry for the late reply. I completely forgot about this PR. |
The `pthread_cond` test uses `nanosleep` which eventually calls `poll_oneoff` but `@bjorn3/browser_wasi_shim` does not implement it. So we skip the test for now, but we will revisit it later once bjorn3/browser_wasi_shim#88 is merged.
e7fa8f9 to
b8a84ba
Compare
This commit adds a blocking-based `poll_oneoff` implementation to support `clock_nanosleep` in wasi-libc. This implementation is very simple and only supports a single subscription for now but is enough for `clock_nanosleep` to work.
b8a84ba to
836aae4
Compare
The `pthread_cond` test uses `nanosleep` which eventually calls `poll_oneoff` but `@bjorn3/browser_wasi_shim` does not implement it. So we skip the test for now, but we will revisit it later once bjorn3/browser_wasi_shim#88 is merged.
|
Thanks! |
|
Published as v0.4.2. |
|
Thanks! |
This release includes a limited polyfill for `poll_oneoff` which is necessary for the `pthread_cond` test to pass in the browser. bjorn3/browser_wasi_shim#88
|
May I ask how this relates to #14? I've been using @igrep's patch for a while now to support |
|
This PR only adds support for sleeping for a certain amount of time. It doesn't do anything with other kinds of subscriptions. @igrep's patch should remain functional even with this PR. It just overwrites the implementation of this PR. |
Update @bjorn3/browser_wasi_shim to version 0.4.2. This release includes a limited polyfill for `poll_oneoff`, which is necessary for the `pthread_cond` test to pass in the browser. bjorn3/browser_wasi_shim#88
This commit adds a blocking-based
poll_oneoffimplementation to supportclock_nanosleepin wasi-libc. This implementation is very simple and only supports a single subscription for now but is enough forclock_nanosleepto work.