Voluntary Servitude
Features
-
Atomic abstractions (
Atomic
,AtomicOption
,FillOnceAtomicOption
,FillOnceAtomicArc
) -
Thread-safe appendable list with a lock-free iterator (
VoluntaryServitude
- also calledVS
) -
Serde serialization (
serde-traits
feature) -
par_extend
,from_par_iter
rayon implementation (rayon-traits
feature) -
Logging (
logs
feature)You probably only need this if you are debugging this crate
Atomic abstractions
- Atomic -> atomic
Box<T>
- AtomicOption -> atomic
Option<Box<T>>
- FillOnceAtomicOption -> atomic
Option<Box<T>>
that can give references (ideal for iterators) - FillOnceAtomicArc -> atomic
Option<Arc<T>>
with a limited API (likeFillOnceAtomicOption
)
With Atomic
and AtomicOption
it's not safe to get a reference, you must replace the value to access it.
To safely get a reference of T you must use FillOnceAtomicOption
and accept the API limitations (initially None
but can be filled once).
For a safe AtomicArc
you must use some data-structure from arc-swap
, RwLock/Mutex
from parking_lot
(or std
, which is slower but the standard) or FillOnceAtomicArc
and accept the limited API (2018).
Licenses
MIT and Apache-2.0
VoluntaryServitude
Examples
Single thread
extern crate voluntary_servitude;
Multi-producer, multi-consumer
extern crate voluntary_servitude;
use ;
const CONSUMERS: usize = 8;
const PRODUCERS: usize = 4;
const ELEMENTS: usize = 10_000_000;