DotNext by Roman Sakno

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

 AtomicInt32

public static class AtomicInt32
Various atomic operations for Int32 data type accessible as extension methods.
public static int AccumulateAndGet(this ref int value, int x, Func<int, int, int> 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 int AccumulateAndGet(this ref int value, int x, ref ValueFunc 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 int AccumulateAndGet(this int[] array, long index, int x, Func<int, int, int> 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 int AccumulateAndGet(this int[] array, long index, int x, ref ValueFunc 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 int Add(this ref int value, int operand)

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

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

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

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

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

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

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

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

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

public static int DecrementAndGet(this ref int value)

Atomically decrements the referenced value by one.

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

Atomically decrements the array element by one.

public static int GetAndAccumulate(this ref int value, int x, Func<int, int, int> 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 int GetAndAccumulate(this ref int value, int x, ref ValueFunc 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 int GetAndAccumulate(this int[] array, long index, int x, Func<int, int, int> 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 int GetAndAccumulate(this int[] array, long index, int x, ref ValueFunc 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 int GetAndSet(this ref int value, int update)

Modifies the referenced value atomically.

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

Modifies the array element atomically.

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

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

public static int GetAndUpdate(this ref int value, ref ValueFunc updater)

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

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

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

public static int GetAndUpdate(this int[] array, long index, ref ValueFunc updater)

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

public static int IncrementAndGet(this ref int value)

Atomically increments the referenced value by one.

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

Atomically increments the array element by one.

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

Modifies the referenced value atomically.

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

Modifies the array element atomically.

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

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

public static int UpdateAndGet(this ref int value, ref ValueFunc updater)

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

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

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

public static int UpdateAndGet(this int[] array, long index, ref ValueFunc updater)

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

public static int VolatileRead(this ref int 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 int VolatileRead(this int[] array, long index)

Performs volatile read of the array element.

public static void VolatileWrite(this ref int value, int 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 VolatileWrite(this int[] array, long index, int value)

Performs volatile write to the array element.