[−][src]Crate safina_sync
This is a safe Rust library for sharing or sending data between async tasks.
It is part of safina
, a safe async runtime.
Features
forbid(unsafe_code)
- Depends only on
std
- Good test coverage (100%)
- Works with
safina-executor
or any async executor
Limitations
- Allocates
Documentation
https://docs.rs/safina-sync
Examples
use std::sync::Arc; use safina_async_test::async_test; use safina_sync::Mutex; let shared_counter: Arc<Mutex<u32>> = get_shared_data(); { let mut counter_guard = shared_counter.lock().await; *counter_guard += 1; // some_async_fn().await; // Cannot await while holding a MutexGuard. } some_async_fn().await; // Await is ok after releasing MutexGuard.
TO DO - Alternatives
- async-lock
- Contains a little
unsafe
code
- Contains a little
- futures-locks
- Contains a little
unsafe
code
- Contains a little
- futures-util
- Very popular
- Full of
unsafe
- tokio-sync
- Very popular
- Fast
- Internally incredibly complicated
- Full of
unsafe
Changelog
- v0.1.0 - First published version
TO DO
- DONE - Implement
Mutex
with tests & docs - DONE - Publish on crates.io
- Add
Barrier
- Add
RwLock
- Add
WaitableBool
- Add
Promise
- Add
Channel
(single receiver) - Add
UnboundedChannel
- Add
WaitableQueue
(multiple receivers) - Add
UnboundedWaitableQueue
- Add
Topic
(copies message to every receiver)
Release Process
- Edit
Cargo.toml
and bump version number. - Run
./release.sh
Structs
LockFuture | |
Mutex | A wrapper around std::sync::Mutex
with an async |
MutexGuard | An RAII
scoped lock of a |