Crate voluntary_servitude

Source
Expand description

Atomic abstractions and thread-safe appendable list with lock-free iterators

§Features

§Atomic abstractions

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).

§Thread-safe appendable list that can create a lock-free iterator

§API of VS Iterator

§Logging

Setup logger according to RUST_LOG env var and logs feature

§Enable the feature:

Cargo.toml

[dependencies]
voluntary_servitude = { version = "4", features = "logs" }

§Set the RUST_LOG env var:

export RUST_LOG=voluntary_servitude=trace
export RUST_LOG=voluntary_servitude=debug
export RUST_LOG=voluntary_servitude=info
export RUST_LOG=voluntary_servitude=warn
export RUST_LOG=voluntary_servitude=error

§Enable the logger using some setup (like env_logger)

env_logger::init();
// Call code to be logged
// ...

Modules§

atomics
Atomic abstractions

Macros§

voluntary_servitude
Creates new VS with specified elements as in the vec! macro
vs
Alias for voluntary_servitude macro

Structs§

Iter
Lock-free iterator based on VS
NotEmpty
Happens when you call try_store in a already filled AtomicOption/FillOnceAtomicOption/FillOnceAtomicArc
VoluntaryServitude
Appendable list with lock-free iterator (also called VS)

Type Aliases§

VS
VoluntaryServitude’s alias