Show / Hide Table of Contents

Class AtomicInt64

Various atomic operations for Int64 data type accessible as extension methods.

Inheritance
Object
AtomicInt64
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public static class AtomicInt64
Remarks

Methods exposed by this class provide volatile read/write of the field even if it is not declared as volatile field.

Methods

| Improve this Doc View Source

AccumulateAndGet(ref Int64, Int64, ValueFunc<Int64, Int64, Int64>)

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

Declaration
public static long AccumulateAndGet(this ref long value, long x, in ValueFunc<long, long, long> accumulator)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Int64 x

Accumulator operand.

ValueFunc<Int64, Int64, Int64> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Int64

The updated value.

Remarks

The function is applied with the current value as its first argument, and the given update as the second argument.

| Improve this Doc View Source

AccumulateAndGet(ref Int64, Int64, Func<Int64, Int64, Int64>)

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

Declaration
public static long AccumulateAndGet(this ref long value, long x, Func<long, long, long> accumulator)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Int64 x

Accumulator operand.

Func<Int64, Int64, Int64> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Int64

The updated value.

Remarks

The function is applied with the current value as its first argument, and the given update as the second argument.

| Improve this Doc View Source

AccumulateAndGet(Int64[], Int64, Int64, ValueFunc<Int64, Int64, Int64>)

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

Declaration
public static long AccumulateAndGet(this long[] array, long index, long x, in ValueFunc<long, long, long> accumulator)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Int64 x

Accumulator operand.

ValueFunc<Int64, Int64, Int64> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Int64

The updated value.

Remarks

The function is applied with the array element as its first argument, and the given update as the second argument.

| Improve this Doc View Source

AccumulateAndGet(Int64[], Int64, Int64, Func<Int64, Int64, Int64>)

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

Declaration
public static long AccumulateAndGet(this long[] array, long index, long x, Func<long, long, long> accumulator)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Int64 x

Accumulator operand.

Func<Int64, Int64, Int64> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Int64

The updated value.

Remarks

The function is applied with the array element as its first argument, and the given update as the second argument.

| Improve this Doc View Source

Add(ref Int64, Int64)

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

Declaration
public static long Add(this ref long value, long operand)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Int64 operand

The value to be added to the currently stored integer.

Returns
Type Description
Int64

Result of sum operation.

| Improve this Doc View Source

Add(Int64[], Int64, Int64)

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

Declaration
public static long Add(this long[] array, long index, long operand)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Int64 operand

The value to be added to the currently stored integer.

Returns
Type Description
Int64

Result of sum operation.

| Improve this Doc View Source

CompareAndSet(ref Int64, Int64, Int64)

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

Declaration
public static bool CompareAndSet(this ref long value, long expected, long update)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Int64 expected

The expected value.

Int64 update

The new value.

Returns
Type Description
Boolean

true if successful. false return indicates that the actual value was not equal to the expected value.

| Improve this Doc View Source

CompareAndSet(Int64[], Int64, Int64, Int64)

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

Declaration
public static bool CompareAndSet(this long[] array, long index, long expected, long update)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Int64 expected

The expected value.

Int64 update

The new value.

Returns
Type Description
Boolean

true if successful. false return indicates that the actual value was not equal to the expected value.

| Improve this Doc View Source

CompareExchange(Int64[], Int64, Int64, Int64)

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

Declaration
public static long CompareExchange(this long[] array, long index, long update, long comparand)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Int64 update

The new value.

Int64 comparand

The expected value.

Returns
Type Description
Int64

The original value of the array element.

| Improve this Doc View Source

DecrementAndGet(ref Int64)

Atomically decrements by one the current value.

Declaration
public static long DecrementAndGet(this ref long value)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Returns
Type Description
Int64

Decremented value.

| Improve this Doc View Source

DecrementAndGet(Int64[], Int64)

Atomically decrements the array element by one.

Declaration
public static long DecrementAndGet(this long[] array, long index)
Parameters
Type Name Description
Int64[] array

The array to write into.

Int64 index

The index of the array element to decrement atomically.

Returns
Type Description
Int64

Decremented array element.

| Improve this Doc View Source

GetAndAccumulate(ref Int64, Int64, ValueFunc<Int64, Int64, Int64>)

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

Declaration
public static long GetAndAccumulate(this ref long value, long x, in ValueFunc<long, long, long> accumulator)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Int64 x

Accumulator operand.

ValueFunc<Int64, Int64, Int64> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Int64

The original value.

Remarks

The function is applied with the current value as its first argument, and the given update as the second argument.

| Improve this Doc View Source

GetAndAccumulate(ref Int64, Int64, Func<Int64, Int64, Int64>)

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

Declaration
public static long GetAndAccumulate(this ref long value, long x, Func<long, long, long> accumulator)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Int64 x

Accumulator operand.

Func<Int64, Int64, Int64> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Int64

The original value.

Remarks

The function is applied with the current value as its first argument, and the given update as the second argument.

| Improve this Doc View Source

GetAndAccumulate(Int64[], Int64, Int64, ValueFunc<Int64, Int64, Int64>)

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

Declaration
public static long GetAndAccumulate(this long[] array, long index, long x, in ValueFunc<long, long, long> accumulator)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Int64 x

Accumulator operand.

ValueFunc<Int64, Int64, Int64> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Int64

The original value of the array element.

Remarks

The function is applied with the array element as its first argument, and the given update as the second argument.

| Improve this Doc View Source

GetAndAccumulate(Int64[], Int64, Int64, Func<Int64, Int64, Int64>)

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

Declaration
public static long GetAndAccumulate(this long[] array, long index, long x, Func<long, long, long> accumulator)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Int64 x

Accumulator operand.

Func<Int64, Int64, Int64> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Int64

The original value of the array element.

Remarks

The function is applied with the array element as its first argument, and the given update as the second argument.

| Improve this Doc View Source

GetAndSet(ref Int64, Int64)

Modifies referenced value atomically.

Declaration
public static long GetAndSet(this ref long value, long update)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Int64 update

A new value to be stored into managed pointer.

Returns
Type Description
Int64

Original value before modification.

| Improve this Doc View Source

GetAndSet(Int64[], Int64, Int64)

Modifies the array element atomically.

Declaration
public static long GetAndSet(this long[] array, long index, long update)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of array element to be modified.

Int64 update

A new value to be stored as array element.

Returns
Type Description
Int64

Original array element before modification.

| Improve this Doc View Source

GetAndUpdate(ref Int64, ValueFunc<Int64, Int64>)

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

Declaration
public static long GetAndUpdate(this ref long value, in ValueFunc<long, long> updater)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

ValueFunc<Int64, Int64> updater

A side-effect-free function.

Returns
Type Description
Int64

The original value.

| Improve this Doc View Source

GetAndUpdate(ref Int64, Func<Int64, Int64>)

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

Declaration
public static long GetAndUpdate(this ref long value, Func<long, long> updater)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Func<Int64, Int64> updater

A side-effect-free function.

Returns
Type Description
Int64

The original value.

| Improve this Doc View Source

GetAndUpdate(Int64[], Int64, ValueFunc<Int64, Int64>)

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

Declaration
public static long GetAndUpdate(this long[] array, long index, in ValueFunc<long, long> updater)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

ValueFunc<Int64, Int64> updater

A side-effect-free function.

Returns
Type Description
Int64

The original value of the array element.

| Improve this Doc View Source

GetAndUpdate(Int64[], Int64, Func<Int64, Int64>)

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

Declaration
public static long GetAndUpdate(this long[] array, long index, Func<long, long> updater)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Func<Int64, Int64> updater

A side-effect-free function.

Returns
Type Description
Int64

The original value of the array element.

| Improve this Doc View Source

IncrementAndGet(ref Int64)

Atomically increments by one referenced value.

Declaration
public static long IncrementAndGet(this ref long value)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Returns
Type Description
Int64

Incremented value.

| Improve this Doc View Source

IncrementAndGet(Int64[], Int64)

Atomically increments the array element by one.

Declaration
public static long IncrementAndGet(this long[] array, long index)
Parameters
Type Name Description
Int64[] array

The array to write into.

Int64 index

The index of the element to increment atomically.

Returns
Type Description
Int64

Incremented array element.

| Improve this Doc View Source

SetAndGet(ref Int64, Int64)

Modifies value atomically.

Declaration
public static long SetAndGet(this ref long value, long update)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Int64 update

A new value to be stored into managed pointer.

Returns
Type Description
Int64

A new value passed as argument.

| Improve this Doc View Source

SetAndGet(Int64[], Int64, Int64)

Modifies the array element atomically.

Declaration
public static long SetAndGet(this long[] array, long index, long update)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of array element to be modified.

Int64 update

A new value to be stored as array element.

Returns
Type Description
Int64

The array element after modification.

| Improve this Doc View Source

UpdateAndGet(ref Int64, ValueFunc<Int64, Int64>)

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

Declaration
public static long UpdateAndGet(this ref long value, in ValueFunc<long, long> updater)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

ValueFunc<Int64, Int64> updater

A side-effect-free function.

Returns
Type Description
Int64

The updated value.

| Improve this Doc View Source

UpdateAndGet(ref Int64, Func<Int64, Int64>)

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

Declaration
public static long UpdateAndGet(this ref long value, Func<long, long> updater)
Parameters
Type Name Description
Int64 value

Reference to a value to be modified.

Func<Int64, Int64> updater

A side-effect-free function.

Returns
Type Description
Int64

The updated value.

| Improve this Doc View Source

UpdateAndGet(Int64[], Int64, ValueFunc<Int64, Int64>)

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

Declaration
public static long UpdateAndGet(this long[] array, long index, in ValueFunc<long, long> updater)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

ValueFunc<Int64, Int64> updater

A side-effect-free function.

Returns
Type Description
Int64

The updated value.

| Improve this Doc View Source

UpdateAndGet(Int64[], Int64, Func<Int64, Int64>)

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

Declaration
public static long UpdateAndGet(this long[] array, long index, Func<long, long> updater)
Parameters
Type Name Description
Int64[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Func<Int64, Int64> updater

A side-effect-free function.

Returns
Type Description
Int64

The updated value.

| Improve this Doc View Source

VolatileRead(ref Int64)

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.

Declaration
public static long VolatileRead(this ref long value)
Parameters
Type Name Description
Int64 value

The field to read.

Returns
Type Description
Int64

The value that was read. This value is the latest written by any processor in the computer, regardless of the number of processors or the state of processor cache.

| Improve this Doc View Source

VolatileRead(Int64[], Int64)

Performs volatile read of the array element.

Declaration
public static long VolatileRead(this long[] array, long index)
Parameters
Type Name Description
Int64[] array

The array to read from.

Int64 index

The array element index.

Returns
Type Description
Int64

The array element.

| Improve this Doc View Source

VolatileWrite(ref Int64, Int64)

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.

Declaration
public static void VolatileWrite(this ref long value, long newValue)
Parameters
Type Name Description
Int64 value

The field where the value is written.

Int64 newValue

The value to write. The value is written immediately so that it is visible to all processors in the computer.

| Improve this Doc View Source

VolatileWrite(Int64[], Int64, Int64)

Performs volatile write to the array element.

Declaration
public static void VolatileWrite(this long[] array, long index, long value)
Parameters
Type Name Description
Int64[] array

The array to write into.

Int64 index

The array element index.

Int64 value

The new value of the array element.

See Also

Interlocked
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX