Fixes#89. Uses @notgull's suggestion of using a `AtomicPtr` with a racy initialization instead of a `OnceCell`.
For the addition of more `unsafe`, I added the `clippy::undocumented_unsafe_blocks` lint at a warn, and fixed a few of the remaining open clippy issues (i.e. `Waker::clone_from` already handling the case where they're equal).
Removing `async_lock` as a dependency shouldn't be a SemVer breaking change.
It turns out that with the current strategy it is possible for tasks to
be stuck in the local queue without any hope of being picked back up.
In practice this seems to happen when the only entities polling the
system are tickers, as opposed to runners. Since tickets don't steal
tasks, it is possible for tasks to be left over in the local queue that
don't filter out.
One possible solution is to make it so tickers steal tasks, but this
kind of defeats the point of tickers. So I've instead elected to replace
the current strategy with one that accounts for the corner cases with
local queues.
The main difference is that I replace the Sleepers struct with two
event_listener::Event's. One that handles tickers subscribed to the
global queue and one that handles tickers subscribed to the local queue.
The other main difference is that each local queue now has a reference
counter. If this count reaches zero, no tasks will be pushed to this
queue. Only runners increment or decrement this counter.
This makes the previously instituted tests pass, so hopefully this works
for most use cases.
Signed-off-by: John Nunley <dev@notgull.net>
Currently, runner local queues rely on a RwLock<Vec<Arc<ConcurrentQueue>>>> to store the queues instead of using actual thread-local storage.
This adds thread_local as a dependency, but this should allow the executor to work steal without needing to hold a lock, as well as allow tasks to schedule onto the local queue directly, where possible, instead of always relying on the global injector queue.
Fixes#62
Co-authored-by: John Nunley <jtnunley01@gmail.com>
Whoops, I accidentally reinvented a semaphore and made the example a lot
more complicated than it needed to be.
Signed-off-by: John Nunley <dev@notgull.net>
`futures-lite` in the dev dependencies added a `block_on` call that was
not present in the WASM build, causing a compile error. This PR makes
sure that the `std` feature of `futures-lite` is enabled in Cargo.toml.
This also adds a CI check to ensure that this doesn't happen again
Signed-off-by: John Nunley <dev@notgull.net>