Based on the previous proposal in [1].
* The Executor is now completely platform-agnostic and only relies on
the platform to provide a type that implements the `PlatformState`
trait.
* The crate provides concrete high-level types rather than forcing users
to deal with trait objects and async-trait. Currently, only File and
Event are supported. Support for timers, sockets, and pipes will be
added in subsequent changes.
* Each high-level type delegates the implementation to a
platform-specific type and exists mainly as a place to hold
documentation and tests.
* On Unix the io_driver module provides async versions of various
IO-related syscalls, which are used by the platform-specific File and
Event types to implement the required behavior.
* io-uring support can be disabled at compile time. When uring support
is enabled, we make a runtime check to decide whether or not to use
it. The actual io-uring driver is currently unimplemented and will be
added in a subsequent change.
One non-trivial downside of this change is that the futures returned by
the various async methods are !Send and !Sync, which means that they can
only be awaited from the same thread on which they were started. In
practice this should be fine since current crosvm (and Chrome OS) code
doesn't really make use of sending futures to different threads. This
can also be mitigated by using `Executor::spawn_local` and a
`oneshot::channel` to isolate the !Send future from the outer async
fn (as long as the output of the future is Send). See the crate
documentation and the `outer_future_is_send` test in `src/executor.rs`
for more details.
[1]: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062166
BUG=b:195468578
TEST=unit tests
Change-Id: I1aad0885e67a957149e2ec3b4d9df215d9b20d81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3222223
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>