crosvm/cros_async
Chirantan Ekbote 8ea889fccf cros_async: Refactor executors
This CL includes several smaller changes to how executors work:

  * Replace BTreeMap with Slab, which should give us some small
    performance benefits by giving O(1) lookups and reducing memory
    allocations when adding new I/O operations. It also gives some
    improvements to readability as we no longer have to carry around
    "next_*" variables. Slab has no dependencies and we're already
    pulling it in via the futures crate.
  * WakerToken no longer implements Clone.
  * Merge pending_ops and completed_ops in URingExecutor into a single
    `ops` Slab and introduce an OpStatus enum that indicates whether an
    operation is pending or completed.  This also fixes a resource leak
    where an operation that was canceled before completion would end up
    staying in completed_ops ~forever. Add a test for this leak.
  * Add a generation number to RingWakerState and include it in all
    RegisteredSources. Since a RegisteredSource can outlive the
    RingWakerState that created it, the generation number ensures that
    it will only affect the RingWakerState that created it. Add a test
    for this.
  * Poison RegisteredSource so that it doesn't implement Send or Sync.
    Since it's associated with a thread-local executor, sending it
    across thread boundaries is not ok.

BUG=none
TEST=unit tests

Change-Id: I43dcfbb8166002995ec8773522c22fab8fb2da9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2374885
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-12 09:39:26 +00:00
..
src cros_async: Refactor executors 2020-09-12 09:39:26 +00:00
Cargo.toml cros_async: Refactor executors 2020-09-12 09:39:26 +00:00