Class AtomicDouble
Various atomic operations for Double data type accessible as extension methods.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public static class AtomicDoubleRemarks
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 SourceAccumulateAndGet(ref Double, Double, ValueFunc<Double, Double, Double>)
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 double AccumulateAndGet(this ref double value, double x, in ValueFunc<double, double, double> accumulator)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Double | x | Accumulator operand. | 
| ValueFunc<Double, Double, Double> | accumulator | A side-effect-free function of two arguments. | 
Returns
| Type | Description | 
|---|---|
| Double | The updated value. | 
Remarks
The function is applied with the current value as its first argument, and the given update as the second argument.
AccumulateAndGet(ref Double, Double, Func<Double, Double, Double>)
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 double AccumulateAndGet(this ref double value, double x, Func<double, double, double> accumulator)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Double | x | Accumulator operand. | 
| Func<Double, Double, Double> | accumulator | A side-effect-free function of two arguments. | 
Returns
| Type | Description | 
|---|---|
| Double | The updated value. | 
Remarks
The function is applied with the current value as its first argument, and the given update as the second argument.
AccumulateAndGet(Double[], Int64, Double, ValueFunc<Double, Double, Double>)
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 double AccumulateAndGet(this double[] array, long index, double x, in ValueFunc<double, double, double> accumulator)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Double | x | Accumulator operand. | 
| ValueFunc<Double, Double, Double> | accumulator | A side-effect-free function of two arguments. | 
Returns
| Type | Description | 
|---|---|
| Double | The updated value. | 
Remarks
The function is applied with the array element as its first argument, and the given update as the second argument.
AccumulateAndGet(Double[], Int64, Double, Func<Double, Double, Double>)
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 double AccumulateAndGet(this double[] array, long index, double x, Func<double, double, double> accumulator)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Double | x | Accumulator operand. | 
| Func<Double, Double, Double> | accumulator | A side-effect-free function of two arguments. | 
Returns
| Type | Description | 
|---|---|
| Double | The updated value. | 
Remarks
The function is applied with the array element as its first argument, and the given update as the second argument.
Add(ref Double, Double)
Adds two 64-bit floating-point numbers and replaces referenced storage with the sum, as an atomic operation.
Declaration
public static double Add(this ref double value, double operand)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Double | operand | The value to be added to the currently stored integer. | 
Returns
| Type | Description | 
|---|---|
| Double | Result of sum operation. | 
Add(Double[], Int64, Double)
Adds two 64-bit integers and replaces array element with the sum, as an atomic operation.
Declaration
public static double Add(this double[] array, long index, double operand)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Double | operand | The value to be added to the currently stored integer. | 
Returns
| Type | Description | 
|---|---|
| Double | Result of sum operation. | 
CompareAndSet(ref Double, Double, Double)
Atomically sets referenced value to the given updated value if the current value == the expected value.
Declaration
public static bool CompareAndSet(this ref double value, double expected, double update)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Double | expected | The expected value. | 
| Double | 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. | 
CompareAndSet(Double[], Int64, Double, Double)
Atomically sets array element to the given updated value if the array element == the expected value.
Declaration
public static bool CompareAndSet(this double[] array, long index, double expected, double update)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Double | expected | The expected value. | 
| Double | 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. | 
CompareExchange(Double[], Int64, Double, Double)
Atomically sets array element to the given updated value if the array element == the expected value.
Declaration
public static double CompareExchange(this double[] array, long index, double update, double comparand)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Double | update | The new value. | 
| Double | comparand | The expected value. | 
Returns
| Type | Description | 
|---|---|
| Double | The original value of the array element. | 
DecrementAndGet(ref Double)
Atomically decrements by one the current value.
Declaration
public static double DecrementAndGet(this ref double value)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
Returns
| Type | Description | 
|---|---|
| Double | Decremented value. | 
DecrementAndGet(Double[], Int64)
Atomically decrements the array element by one.
Declaration
public static double DecrementAndGet(this double[] array, long index)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to write into. | 
| Int64 | index | The index of the array element to decrement atomically. | 
Returns
| Type | Description | 
|---|---|
| Double | Decremented array element. | 
GetAndAccumulate(ref Double, Double, ValueFunc<Double, Double, Double>)
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 double GetAndAccumulate(this ref double value, double x, in ValueFunc<double, double, double> accumulator)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Double | x | Accumulator operand. | 
| ValueFunc<Double, Double, Double> | accumulator | A side-effect-free function of two arguments. | 
Returns
| Type | Description | 
|---|---|
| Double | The original value. | 
Remarks
The function is applied with the current value as its first argument, and the given update as the second argument.
GetAndAccumulate(ref Double, Double, Func<Double, Double, Double>)
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 double GetAndAccumulate(this ref double value, double x, Func<double, double, double> accumulator)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Double | x | Accumulator operand. | 
| Func<Double, Double, Double> | accumulator | A side-effect-free function of two arguments. | 
Returns
| Type | Description | 
|---|---|
| Double | The original value. | 
Remarks
The function is applied with the current value as its first argument, and the given update as the second argument.
GetAndAccumulate(Double[], Int64, Double, ValueFunc<Double, Double, Double>)
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 double GetAndAccumulate(this double[] array, long index, double x, in ValueFunc<double, double, double> accumulator)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Double | x | Accumulator operand. | 
| ValueFunc<Double, Double, Double> | accumulator | A side-effect-free function of two arguments. | 
Returns
| Type | Description | 
|---|---|
| Double | 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.
GetAndAccumulate(Double[], Int64, Double, Func<Double, Double, Double>)
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 double GetAndAccumulate(this double[] array, long index, double x, Func<double, double, double> accumulator)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Double | x | Accumulator operand. | 
| Func<Double, Double, Double> | accumulator | A side-effect-free function of two arguments. | 
Returns
| Type | Description | 
|---|---|
| Double | 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.
GetAndSet(ref Double, Double)
Modifies referenced value atomically.
Declaration
public static double GetAndSet(this ref double value, double update)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Double | update | A new value to be stored into managed pointer. | 
Returns
| Type | Description | 
|---|---|
| Double | Original value before modification. | 
GetAndSet(Double[], Int64, Double)
Modifies the array element atomically.
Declaration
public static double GetAndSet(this double[] array, long index, double update)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of array element to be modified. | 
| Double | update | A new value to be stored as array element. | 
Returns
| Type | Description | 
|---|---|
| Double | Original array element before modification. | 
GetAndUpdate(ref Double, ValueFunc<Double, Double>)
Atomically updates the stored value with the results of applying the given function, returning the original value.
Declaration
public static double GetAndUpdate(this ref double value, in ValueFunc<double, double> updater)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| ValueFunc<Double, Double> | updater | A side-effect-free function. | 
Returns
| Type | Description | 
|---|---|
| Double | The original value. | 
GetAndUpdate(ref Double, Func<Double, Double>)
Atomically updates the stored value with the results of applying the given function, returning the original value.
Declaration
public static double GetAndUpdate(this ref double value, Func<double, double> updater)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Func<Double, Double> | updater | A side-effect-free function. | 
Returns
| Type | Description | 
|---|---|
| Double | The original value. | 
GetAndUpdate(Double[], Int64, ValueFunc<Double, Double>)
Atomically updates the array element with the results of applying the given function, returning the original value.
Declaration
public static double GetAndUpdate(this double[] array, long index, in ValueFunc<double, double> updater)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| ValueFunc<Double, Double> | updater | A side-effect-free function. | 
Returns
| Type | Description | 
|---|---|
| Double | The original value of the array element. | 
GetAndUpdate(Double[], Int64, Func<Double, Double>)
Atomically updates the array element with the results of applying the given function, returning the original value.
Declaration
public static double GetAndUpdate(this double[] array, long index, Func<double, double> updater)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Func<Double, Double> | updater | A side-effect-free function. | 
Returns
| Type | Description | 
|---|---|
| Double | The original value of the array element. | 
IncrementAndGet(ref Double)
Atomically increments by one referenced value.
Declaration
public static double IncrementAndGet(this ref double value)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
Returns
| Type | Description | 
|---|---|
| Double | Incremented value. | 
IncrementAndGet(Double[], Int64)
Atomically increments the array element by one.
Declaration
public static double IncrementAndGet(this double[] array, long index)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to write into. | 
| Int64 | index | The index of the element to increment atomically. | 
Returns
| Type | Description | 
|---|---|
| Double | Incremented array element. | 
SetAndGet(ref Double, Double)
Modifies value atomically.
Declaration
public static double SetAndGet(this ref double value, double update)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Double | update | A new value to be stored into managed pointer. | 
Returns
| Type | Description | 
|---|---|
| Double | A new value passed as argument. | 
SetAndGet(Double[], Int64, Double)
Modifies the array element atomically.
Declaration
public static double SetAndGet(this double[] array, long index, double update)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of array element to be modified. | 
| Double | update | A new value to be stored as array element. | 
Returns
| Type | Description | 
|---|---|
| Double | The array element after modification. | 
UpdateAndGet(ref Double, ValueFunc<Double, Double>)
Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declaration
public static double UpdateAndGet(this ref double value, in ValueFunc<double, double> updater)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| ValueFunc<Double, Double> | updater | A side-effect-free function. | 
Returns
| Type | Description | 
|---|---|
| Double | The updated value. | 
UpdateAndGet(ref Double, Func<Double, Double>)
Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declaration
public static double UpdateAndGet(this ref double value, Func<double, double> updater)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | Reference to a value to be modified. | 
| Func<Double, Double> | updater | A side-effect-free function. | 
Returns
| Type | Description | 
|---|---|
| Double | The updated value. | 
UpdateAndGet(Double[], Int64, ValueFunc<Double, Double>)
Atomically updates the array element with the results of applying the given function, returning the updated value.
Declaration
public static double UpdateAndGet(this double[] array, long index, in ValueFunc<double, double> updater)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| ValueFunc<Double, Double> | updater | A side-effect-free function. | 
Returns
| Type | Description | 
|---|---|
| Double | The updated value. | 
UpdateAndGet(Double[], Int64, Func<Double, Double>)
Atomically updates the array element with the results of applying the given function, returning the updated value.
Declaration
public static double UpdateAndGet(this double[] array, long index, Func<double, double> updater)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to be modified. | 
| Int64 | index | The index of the array element to be modified. | 
| Func<Double, Double> | updater | A side-effect-free function. | 
Returns
| Type | Description | 
|---|---|
| Double | The updated value. | 
VolatileRead(ref Double)
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 double VolatileRead(this ref double value)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | The field to read. | 
Returns
| Type | Description | 
|---|---|
| Double | 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. | 
VolatileRead(Double[], Int64)
Performs volatile read of the array element.
Declaration
public static double VolatileRead(this double[] array, long index)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to read from. | 
| Int64 | index | The array element index. | 
Returns
| Type | Description | 
|---|---|
| Double | The array element. | 
VolatileWrite(ref Double, Double)
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 double value, double newValue)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | The field where the value is written. | 
| Double | newValue | The value to write. The value is written immediately so that it is visible to all processors in the computer. | 
VolatileWrite(Double[], Int64, Double)
Performs volatile write to the array element.
Declaration
public static void VolatileWrite(this double[] array, long index, double value)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | The array to write into. | 
| Int64 | index | The array element index. | 
| Double | value | The new value of the array element. |