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

Optionally disable timers or Asyncs on features #89

Open
notgull opened this issue Aug 22, 2022 · 4 comments · May be fixed by #153
Open

Optionally disable timers or Asyncs on features #89

notgull opened this issue Aug 22, 2022 · 4 comments · May be fixed by #153

Comments

@notgull
Copy link
Member

notgull commented Aug 22, 2022

WASM targets don't support Async and probably won't until WASI reaches a more stable point. However, since parking is usable on WASM thanks to atomics, it may be desirable to use the Timer implementation.

My suggestion is to add two new features: io and timers. They compose as such:

  • With both features enabled (they are by default), the crate functions as normal.
  • With io disabled but timers enabled, the Reactor retains its timer processing capabilities but instead of calling to polling, it calls parking (which works with WASM) with the timeout resulting from process_timer_ops.
  • With both features disabled, Reactor no longer exists and block_on is just an alias to the ones in futures_lite.

This would be a breaking change.

@taiki-e
Copy link
Collaborator

taiki-e commented Sep 8, 2022

I'm not sure if we need to introduce such a breaking change to support WASM.
Currently, async-io fails to compile on WASM anyway, so I think just disabling some APIs in WASM is not a problem.

@notgull
Copy link
Member Author

notgull commented Sep 8, 2022

That's probably the best way of going about this. I'll rearrange the PR I wrote to use OS flags instead of feature flags.

@notgull
Copy link
Member Author

notgull commented Dec 1, 2022

A few points of note I discovered while implementing this:

  • Instant::now() is unimplemented for WASM, which means we'd have to use instant or something similar. However with the current API of Timer this means that instant would be in the public API, unless we made at or interval_at unavailable for WASM.
  • In order for the condvar waiting to work, the -Ctarget-feature=+atomics flag needs to be enabled. However, trying to rebuild libstd with that gives me an ICE. I'll investigate more before I file a Rust bug.

@notgull notgull linked a pull request Sep 24, 2023 that will close this issue
@notgull
Copy link
Member Author

notgull commented Feb 4, 2024

Not relevant for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants