-
Notifications
You must be signed in to change notification settings - Fork 37
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
Make blocking APIs optionally async #100
Conversation
Personally I would completely forego blocking variants of those methods and make all of them async. The readme states |
The But then it seems kind of silly to do what is effectively |
3986e70
to
8532a37
Compare
`DeviceInfo::open`, `Device::from_fd`, `Device::set_configuration`, `Device::reset`, `Interface::set_alt_setting`, `Interface::clear_halt` all perform IO but are currently blocking because the underlying OS APIs are blocking. `list_devices`,`list_buses`, `Device::claim_interface` `Device::detach_and_claim_interface` theoretically don't perform IO, but are also included here because they need to be async on WebUSB. The `IoAction` trait allows defering these actions to the thread pool from the `blocking` crate when used asynchronously with `.await` / `IntoFuture`, or directly runs the blocking syscall synchronously with a `.wait()` method.
8532a37
to
a4662e6
Compare
Fair point :) That's actually a really nice way to do this :) I think we can merge this as is :) |
How are we looking on this? :) I would love to round up my WebUSB backend PR :) |
9ff6180
to
11b8fe4
Compare
Renamed it, but I think it's ready. |
DeviceInfo::open
,Device::from_fd
,Device::set_configuration
,Device::reset
,Interface::set_alt_setting
,Interface::clear_halt
all perform IO but are currently blocking because the underlying OS APIs are blocking.list_devices
,list_buses
,Device::claim_interface
Device::detach_and_claim_interface
theoretically don't perform IO, but are also included here because they need to be async on WebUSB.The
IoAction
trait allows defering these actions to the thread pool from theblocking
crate when used asynchronously with.await
/IntoFuture
, or directly runs the blocking syscall synchronously with a.wait()
method.Open question: Should the dependency on
blocking
be behind a cargo feature, and if unset, shouldIoAction
not implIntoFuture
or should it return a dummy Future that runs synchronously?