DotNext by Roman Sakno

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

 AtomicLong

public static class AtomicLong
Various atomic operations for Int64 data type accessible as extension methods.
public static long AccumulateAndGet(this ref long value, long x, Func<long, long, long> accumulator)

Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.

public static long AccumulateAndGet(this long[] array, long index, long x, Func<long, long, long> accumulator)

Atomically updates the array element with the results of applying the given function to the array element and given values, returning the updated value.

public static long Add(this ref long value, long operand)

Adds two 64-bit integers and replaces referenced integer with the sum, as an atomic operation.

public static long Add(this long[] array, long index, long operand)

Adds two 64-bit integers and replaces array element with the sum, as an atomic operation.

public static bool CompareAndSet(this ref long value, long expected, long update)

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

public static bool CompareAndSet(this long[] array, long index, long expected, long update)

Atomically sets array element to the given updated value if the array element == the expected value.

public static long CompareExchange(this long[] array, long index, long update, long comparand)

Atomically sets array element to the given updated value if the array element == the expected value.

public static long DecrementAndGet(this ref long value)

Atomically decrements by one the current value.

public static long DecrementAndGet(this long[] array, long index)

Atomically decrements the array element by one.

public static long GetAndAccumulate(this ref long value, long x, Func<long, long, long> accumulator)

Atomically updates the current value with the results of applying the given function to the current and given values, returning the original value.

public static long GetAndAccumulate(this long[] array, long index, long x, Func<long, long, long> accumulator)

Atomically updates the array element with the results of applying the given function to the array element and given values, returning the original value.

public static long GetAndSet(this ref long value, long update)

Modifies referenced value atomically.

public static long GetAndSet(this long[] array, long index, long update)

Modifies the array element atomically.

public static long GetAndUpdate(this ref long value, Func<long, long> updater)

Atomically updates the stored value with the results of applying the given function, returning the original value.

public static long GetAndUpdate(this long[] array, long index, Func<long, long> updater)

Atomically updates the array element with the results of applying the given function, returning the original value.

public static long IncrementAndGet(this ref long value)

Atomically increments by one referenced value.

public static long IncrementAndGet(this long[] array, long index)

Atomically increments the array element by one.

public static long SetAndGet(this ref long value, long update)

Modifies value atomically.

public static long SetAndGet(this long[] array, long index, long update)

Modifies the array element atomically.

public static long UpdateAndGet(this ref long value, Func<long, long> updater)

Atomically updates the stored value with the results of applying the given function, returning the updated value.

public static long UpdateAndGet(this long[] array, long index, Func<long, long> updater)

Atomically updates the array element with the results of applying the given function, returning the updated value.

public static long VolatileGet(this ref long value)

Reads the value of the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears after this method in the code, the processor cannot move it before this method.

public static long VolatileGet(this long[] array, long index)

Performs volatile read of the array element.

public static void VolatileSet(this ref long value, long newValue)

Writes the specified value to the specified field. On systems that require it, inserts a memory barrier that prevents the processor from reordering memory operations as follows: If a read or write appears before this method in the code, the processor cannot move it after this method.

public static void VolatileSet(this long[] array, long index, long value)

Performs volatile write to the array element.