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) -
Diesel Insertable implementation (
diesel-traits
ordiesel-sqlite
feature)Implements
Insertable
for&VS
and&Iter
Sqlite backend is not supported since it doesn't really support batch inserts and we can't implement the traits needed to mock it (orphan rules), use a transaction and insert them individually (https://github.com/diesel-rs/diesel/issues/1177)
-
par_extend
,from_par_iter
rayon implementation (rayon-traits
feature) -
Logging (
logs
feature)
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 to 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;