DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="2.10.1" />

 Atomic<T>

public struct Atomic<T> : IStrongBox, ICloneable where T : struct
Provides atomic access to non-primitive data type.
public sealed delegate Accumulator<T> : MulticastDelegate where T : struct

Represents atomic accumulator.

public sealed delegate Updater<T> : MulticastDelegate where T : struct

Represents atomic update action.

public T Value { get; set; }

Gets or sets value atomically.

public void AccumulateAndGet(ref T x, Accumulator<T> accumulator, out T result)

public Atomic<T> Clone()

Clones this container atomically.

public bool CompareAndSet(ref T expected, ref T update)

Atomically sets the stored value to the given updated value if the current value == the expected value.

public bool CompareExchange(ref T update, ref T expected, out T result)

Compares two values of type T for bitwise equality and, if they are equal, replaces the stored value.

public void Exchange(ref T update, out T previous)

Sets a value stored in this container to a specified value and returns the original value, as an atomic operation.

public void GetAndAccumulate(ref T x, Accumulator<T> accumulator, out T result)

public void GetAndUpdate(Updater<T> updater, out T result)

public void Read(out T result)

Performs atomic read.

public void Swap(ref Atomic other)

Swaps the value stored in this container and the given value atomically.

public void Swap(ref T other)

Swaps the value stored in this container and the given value atomically.

public void UpdateAndGet(Updater<T> updater, out T result)

public void Write(ref T newValue)

Performs atomic write.