5 releases

0.1.4 Dec 29, 2020
0.1.3 Dec 23, 2020
0.1.2 Dec 13, 2020
0.1.1 Dec 12, 2020
0.1.0 Dec 12, 2020

#184 in Asynchronous

40 downloads per month
Used in less than 7 crates

Apache-2.0

71KB
897 lines

safina-executor

crates.io version license: Apache 2.0 unsafe forbidden pipeline status

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 Wake trait
  • Allocates memory
  • Not optimized

Documentation

https://docs.rs/safina-executor

Examples

let executor = safina_executor::Executor::default();
let (sender, receiver) = std::sync::mpsc::channel();
executor.spawn(async move {
    sender.send(()).unwrap();
});
receiver.recv().unwrap();
let result = safina_executor::block_on(async {
    prepare_request().await?;
    execute_request().await
})?;
let result = safina_executor::schedule_blocking(|| {
    read_file1()?;
    read_file2()
}).await?;

Alternatives

Changelog

  • v0.1.4 - Add schedule_blocking and Executor::schedule_blocking
  • v0.1.3
    • Removed global executor. Users must explicitly create executor.
    • Removed dependency on unstable OnceCell.
    • Uses safina_threadpool internally.
  • v0.1.2 - Let callers pass futures to spawn and block_on without using Box::pin. Add spawn_unpin and block_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, and increase_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. See benchmarks in https://crates.io/crates/executors
  • Make a version of the crate that uses unsafe once_cell and unsafe RawWaker and builds with Rust stable.
  • Add an #[async_main] macro

Release Process

  1. Edit Cargo.toml and bump version number.
  2. Run ./release.sh

License: Apache-2.0

Dependencies