DotNext by .NET Foundation and Contributors

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

 AtomicInt64

public static class AtomicInt64
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 ref long value, long x, method accumulator)

public static long AddAndGet(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 BitwiseAndAndGet(this ref long value, long operand)

Bitwise "ands" two 64-bit integers and replaces referenced integer with the result, as an atomic operation.

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

Bitwise "ors" two 64-bit integers and replaces referenced integer with the result, as an atomic operation.

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

Bitwise "xors" two 64-bit integers and replaces referenced integer with the result, 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 long DecrementAndGet(this ref long value)

Atomically decrements by one the current value.

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 ref long value, long x, method accumulator)

public static long GetAndAdd(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 GetAndBitwiseAnd(this ref long value, long operand)

Bitwise "ands" two 64-bit integers and replaces referenced integer with the result, as an atomic operation.

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

Bitwise "ors" two 64-bit integers and replaces referenced integer with the result, as an atomic operation.

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

Bitwise "xors" two 64-bit integers and replaces referenced integer with the result, as an atomic operation.

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

Modifies referenced value 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 ref long value, method updater)

public static long IncrementAndGet(this ref long value)

Atomically increments by one referenced value.

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

Modifies value 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 ref long value, method updater)

public static long VolatileRead(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 void VolatileWrite(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.