Skip to content

Commit

Permalink
Update README to reflect changes to the implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tmccombs committed Feb 18, 2020
1 parent ce2c7ab commit e9df3a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
@@ -1,5 +1,6 @@
[package]
name = "waitlist"
description = "Keep track of an ordered list of Wakers to wake"
version = "0.1.0"
authors = ["Thayne McCombs <astrothayne@gmail.com>"]
edition = "2018"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -14,5 +14,5 @@ The implementation (and API) pulls heavily from the [`waker_set`](https://github

This implementation differs from the `waker_set` implementation and patterns followed in the `futures-util` crate. Specifically:
1. The order in which tasks are notified is more fair. `Waitlist` uses a FIFO queue for notifying waiting tasks, whereas the usage of `slab` in other implementations can result in task starvation in certains situations (see https://users.rust-lang.org/t/concerns-about-using-slab-to-track-wakers/33653).
2. Removing an entry from the list is potentially `O(n)` rather than `O(1)`. This is a bit of a tradeoff. Using a single linked list instead of a double linked list reduces complexity, as well as the amount of memory needed for each entry, but also means removal is more expensive. Using slab gets `O(1)` removal because it doesn't care about the order of the entries. On the other hand, notifying a single entry is `O(1)` with `Waitlist`, and notifying all waiting only has to iterate through waiting entries, whereas with slab it is necessary to iterate through the entire capacity of the slab.
3. `WaitList` uses atomics to synchronize similar to `async-std` and unlike `futures-util` which uses a `Mutex`.
2. Removing an entry from the list is potentially `O(n)` rather than `O(1)`. This is a bit of a tradeoff. Using slab gets `O(1)` removal because it doesn't care about the order of the entries. On the other hand, notifying a single entry is `O(1)` with `Waitlist`, and notifying all waiting only has to iterate through waiting entries, whereas with slab it is necessary to iterate through the entire capacity of the slab. Also, if an entry has already been woken in `Waitlist`, "removal" is still only `O(1)` (because it is really just decrementing a counter).
3. `WaitList` uses std::sync::Mutex to synchronize similar to `futures-util` and unlike `async-std` which uses a `Mutex`.

0 comments on commit e9df3a7

Please sign in to comment.