[−][src]Crate safina_executor
This is a safe Rust async executor.
It is part of safina
, a safe async runtime.
Features
forbid(unsafe_code)
- Depends only on
std
- Good test coverage (100%)
Limitations
- Requires Rust
nightly
, for OnceCell and Wake trait - Allocates memory
- Not optimized
Documentation
https://docs.rs/safina-executor
Examples
safina_executor::increase_threads_to(1); let (sender, receiver) = std::sync::mpsc::channel(); safina_executor::spawn(async move { sender.send(()).unwrap(); }); receiver.recv().unwrap();
std::thread::spawn(safina_executor::work); let result = safina_executor::block_on(async { prepare_request().await?; execute_request().await })?;
Alternatives
- smol
- popular
- Contains generous amounts of
unsafe
code
- async-std
- popular
- Contains generous amounts of
unsafe
code
- tokio
- very popular
- Fast, internally complicated, and full of
unsafe
- nostd_async
Changelog
- v0.1.2 - Let callers pass futures to
spawn
andblock_on
without usingBox::pin
. Addspawn_unpin
andblock_on_unpin
for folks who need to avoid allocating. so callers don't have to. - v0.1.1 - Fix badge and update readme
- v0.1.0 - Renamed from
safina
TO DO
- DONE - Implement
spawn
- DONE - Implement
block_on
- DONE - Implement
increase_threads_to
- DONE - Drop finished futures
- DONE - Handle task panic
- DONE - Add
stop_threads
,allow_threads
, andincrease_threads_to
. - DONE - Add tests
- DONE - Add docs
- DONE - Publish on crates.io
- DONE - Add an #[async_test] macro
- Add a stress test
- Add a benchmark
- Make a version of the crate that uses
unsafe
once_cell
and unsafeRawWaker
and builds with Ruststable
. - Add an #[async_main] macro
Release Process
- Edit
Cargo.toml
and bump version number. - Run
./release.sh
Structs
ThreadStopTimeout | Returned by |
Functions
allow_threads | Clears the signal for worker threads to stop.
Call this after |
block_on | Executes the future on the current thread and returns its result. Panics if the future panics. |
block_on_unpin | Executes the future on the current thread and returns its result. Panics if the future panics. |
increase_threads_to | Spawns new worker threads until the total number of workers is |
num_threads_running | The number of worker threads currently running. |
spawn | Adds a task that will execute |
spawn_unpin | Adds a task that will execute |
stop_threads | Signals all threads to stop. Waits for them all to stop. |
work | Use the current thread as a worker in the runtime. |