crosvm/common/cros_asyncv2/Cargo.toml
Chirantan Ekbote 7b13ef3ea6 cros_asyncv2: Add crate
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>
2021-12-09 12:33:02 +00:00

32 lines
800 B
TOML

[package]
name = "cros_async"
version = "0.2.0"
edition = "2018"
[features]
uring = ["io-uring"]
[dependencies]
anyhow = "1"
async-task = "4"
data_model = { path = "../data_model" } # provided by ebuild
futures = { version = "0.3", default-features = false, features = ["alloc"] }
intrusive-collections = "0.9"
io-uring = { version = "0.5", optional = true }
once_cell = "1.7"
slab = "0.4"
sync = { path = "../sync" } # provided by ebuild
thiserror = "1"
[target.'cfg(unix)'.dependencies]
libc = "0.2"
mio = { version = "0.7", features = ["os-ext"] }
sys_util = { path = "../sys_util" } # provided by ebuild
[dev-dependencies]
futures = { version = "*", features = ["executor"] }
futures-executor = { version = "0.3", features = ["thread-pool"] }
futures-util = "0.3"
tempfile = "3"
[workspace]