Expand description
Run futures on a Tao or winit event-loop thread.
taao bridges the Tao or winit event loop and async Rust: it drives the event loop on the current thread while polling a future, and notifies the event-loop thread through the event-loop proxy whenever the future is woken.
Exactly one backend feature must be enabled: tao (default) or winit.
§Running a future
Call EventLoopBlockOn::block_on on the backend event loop; it returns the future’s
output once the future completes:
use taao::EventLoopBlockOn;
let mut event_loop = tao::event_loop::EventLoop::new();
let answer = event_loop.block_on(async { 42 })?;
assert_eq!(answer, 42);With the winit feature, the same call works on the winit event loop.
§Events and event-loop operations
With the event feature, EventLoopBlockOn::block_on_with_events additionally hands
the future an event::Event: a stream of backend events plus event::Submitter::submit
for running closures on the event-loop thread. Use event::Event::submitter to get
a cloneable handle for submitting from separate tasks. Import taao::event::Submitter
to call .submit(...) on either handle. See the event module.
§Features
| Feature | Description | Default |
|---|---|---|
tao | Use the Tao backend | Yes |
winit | Use the winit backend | No |
event | Enable the event stream and Submitter::submit | No |
tracing | Enable diagnostic logging | No |
Modules§
- event
event - Event streams and event-loop operations, available with the
eventfeature.
Enums§
- Block
OnError - Error returned when driving a future on the event-loop thread fails.
Traits§
- Event
Loop Block On taoand non-iOS, orwinitand neither iOS nor WebAssembly - Extension trait that runs a future to completion on the backend’s event-loop thread.