[][src]Crate conquer_util

Common utilities for lock-free and concurrent programming.

This crate provides fine-grained control over its contents through cargo feature flags:

#![no_std] Compatibility

By default, conquer-utils enables the std feature, which links against the standard library and requires e.g. OS support. Disabling this feature allows this crate to be used in #![no_std] environments. If the targeted environment does not allow using std features but provides the means for dynamic memory allocation, the alloc feature can be used to enable additional functionality. Note that the std feature implicitly activates all alloc features as well.

Features

The following utilities are provided when compiling this crate with the appropriate feature flags:

Alignment

When the align feature is enabled, the same-named module can be used, which provides generic thin wrapper types for specifying the alignment for instances of the respective type. Particularly useful is the CacheAligned type, which forces an alignment to the size of a cache-line. This helps to avoid false sharing. The provided types can be used in their entirety in a #![no_std] environment.

Back-Off

By enabling the back-off feature, this crate provides the BackOff type, which can be used to perform exponential back-off in e.g. spin-loops. This type is #![no_std] compatible, but provides additional features when the std feature is also enabled.

Randomized Exponential Back-Off

Enabling the random feature in addition to the back-off feature pulls in the rand dependency and additionally adds #![no_std] compatible randomized exponential back-off, which adds some slight variations the time each thread spends spinning. This may help avoid issues such as convoying.

TLS

Enabling the tls feature makes the BoundedThreadLocal available, which is useful for iterable per-object thread local storage for bounded numbers of threads.

Modules

align

Transparent thin wrapper types for artificially increasing the alignment of the wrapped type.

Structs

BackOff

A type for exponential back-off in tight loops.

BoundedThreadLocal

A lock-free bounded per-value thread local storage.

BoundsError

An Error for signalling than more than the specified maximum number of threads attempted to access a BoundedThreadLocal.

IntoIter

An owning iterator that can be created from an owned BoundedThreadLocal.

IterMut

A iterator that can be created from an unique reference to a BoundedThreadLocal.

Local

A wrapper for an instance of T that can be managed by a BoundedThreadLocal.

Token

A thread local token granting unique access to an instance of T that is contained in a BoundedThreadLocal