DotNext by .NET Foundation and Contributors

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

 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 CompareAndSet(Func<T, T, bool> comparer, 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 CompareAndSet(method comparer, ref T expected, ref T update)

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 bool CompareExchange(Func<T, T, bool> comparer, ref T update, ref T expected, out T result)

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

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

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.