16 releases
0.3.3 | Apr 1, 2022 |
---|---|
0.3.2 | Mar 24, 2022 |
0.2.1 | Feb 25, 2022 |
0.1.10 | Jun 25, 2021 |
0.1.7 | Dec 29, 2020 |
#1162 in Asynchronous
42 downloads per month
Used in permit
65KB
848 lines
safina
A safe Rust async runtime.
This crate simply re-exports the various safina-*
crates.
Features
forbid(unsafe_code)
- Depends only on
std
- Good test coverage (>95%)
Limitations
- Building on
stable
requiresonce_cell
crate which contains some unsafe code. This is necessary untilstd::lazy::OnceCell
is stable. - No
fs
module yet.async-fs
is a fast async networking library that works well with Safina. It contains some unsafe code. net
module has poor performance.async-net
is a fast async networking library that works well with Safina. It contains some unsafe code.- Not optimized
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
})?;
Related
safina_async_test
crate has an#[async_test]
macro for runningasync fn
test functions.
Alternatives
smol
- Popular
- Contains some
unsafe
code
async-std
- Very popular
- Contains generous amounts of
unsafe
code
futures
- Very popular
- Contains generous amounts of
unsafe
code
tokio
- Very popular
- Fast
- Internally extremely complicated
- Full of
unsafe
code
bastion
- Generous amounts of
unsafe
code
- Generous amounts of
nostd_async
Changelog
Changelog
- v0.3.3 - Update docs.
- v0.3.2 - Add
threadpool
module. - v0.3.1
- Add
sync_channel
andSyncSender
. - Add
Receiver::async_recv
to let users await without writing ugly(&mut receiver).await
. - Remove
Receiver::blocking
and addtry_recv
,recv
, etc.
- Add
- v0.3.0
- Move structs into sub-modules.
- Replace
Promise
withoneshot
,OneSender
, andReceiver
that supports async and blocking reads. schedule_blocking
to return newsync::Receiver
.
- v0.2.1 - Update docs.
- v0.2.0
Executor::new
andExecutor::with_name
to returnResult
.ThreadPool::new
to returnResult
.ThreadPool::try_schedule
to return an error when it fails to restart panicked threads.ThreadPool::schedule
to handle failure starting replacement threads.
- v0.1.10 -
block_on
functions to take futures that are notSend
. - v0.1.9 - Use
once_cell
by default. - v0.1.8 - Support stable with rust 1.51 and
once_cell
. - v0.1.7 - Add
safina-net
- v0.1.6 - Use
safina-executor
v0.1.3 API - v0.1.5 - Add
safina_sync::Mutex
- v0.1.4 - Upgrade to new safina-executor version which removes need for
Box::pin
. - v0.1.3 - Update docs
- v0.1.2 - Renamed
safina
crate tosafina-executor
. Added newsafina
crate with re-exports, examples, and integration tests. - v0.1.1 - Add badges to readme
- v0.1.0 - First published version
TO DO
- Add
init
function that makes an executor and starts the timer thread. - Add an
#[async_main]
macro
License: Apache-2.0