Show / Hide Table of Contents

Class AtomicReference

Provides atomic operations for the reference type.

Inheritance
Object
AtomicReference
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 AtomicReference

Methods

| Improve this Doc View Source

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

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 T AccumulateAndGet<T>(ref T value, T x, in ValueFunc<T, T, T> accumulator)

    where T : class
Parameters
Type Name Description
T value

The value to update.

T x

Accumulator operand.

ValueFunc<T, T, T> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
T

The updated value.

Type Parameters
Name Description
T

Type of value in the memory storage.

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<T>(ref T, T, Func<T, T, T>)

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 T AccumulateAndGet<T>(ref T value, T x, Func<T, T, T> accumulator)

    where T : class
Parameters
Type Name Description
T value

The value to update.

T x

Accumulator operand.

Func<T, T, T> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
T

The updated value.

Type Parameters
Name Description
T

Type of value in the memory storage.

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<T>(T[], Int64, T, ValueFunc<T, T, T>)

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 T AccumulateAndGet<T>(this T[] array, long index, T x, in ValueFunc<T, T, T> accumulator)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

T x

Accumulator operand.

ValueFunc<T, T, T> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
T

The updated value.

Type Parameters
Name Description
T

The type of the elements in array.

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<T>(T[], Int64, T, Func<T, T, T>)

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 T AccumulateAndGet<T>(this T[] array, long index, T x, Func<T, T, T> accumulator)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

T x

Accumulator operand.

Func<T, T, T> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
T

The updated value.

Type Parameters
Name Description
T

The type of the elements in array.

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

CompareAndSet<T>(ref T, T, T)

Compares two values for equality and, if they are equal, replaces the stored value.

Declaration
public static bool CompareAndSet<T>(ref T value, T expected, T update)

    where T : class
Parameters
Type Name Description
T value

The value to update.

T expected

The expected value.

T 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.

Type Parameters
Name Description
T

Type of value in the memory storage.

| Improve this Doc View Source

CompareAndSet<T>(T[], Int64, T, T)

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

Declaration
public static bool CompareAndSet<T>(this T[] array, long index, T expected, T update)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

T expected

The expected value.

T 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.

Type Parameters
Name Description
T

The type of the elements in array.

| Improve this Doc View Source

CompareExchange<T>(T[], Int64, T, T)

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

Declaration
public static T CompareExchange<T>(this T[] array, long index, T update, T comparand)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

T update

The new value.

T comparand

The expected value.

Returns
Type Description
T

The original value of the array element.

Type Parameters
Name Description
T

The type of the elements in array.

| Improve this Doc View Source

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

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 T GetAndAccumulate<T>(ref T value, T x, in ValueFunc<T, T, T> accumulator)

    where T : class
Parameters
Type Name Description
T value

The value to update.

T x

Accumulator operand.

ValueFunc<T, T, T> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
T

The original value.

Type Parameters
Name Description
T

Type of value in the memory storage.

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<T>(ref T, T, Func<T, T, T>)

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 T GetAndAccumulate<T>(ref T value, T x, Func<T, T, T> accumulator)

    where T : class
Parameters
Type Name Description
T value

The value to update.

T x

Accumulator operand.

Func<T, T, T> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
T

The original value.

Type Parameters
Name Description
T

Type of value in the memory storage.

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<T>(T[], Int64, T, ValueFunc<T, T, T>)

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 T GetAndAccumulate<T>(this T[] array, long index, T x, in ValueFunc<T, T, T> accumulator)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

T x

Accumulator operand.

ValueFunc<T, T, T> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
T

The original value of the array element.

Type Parameters
Name Description
T

The type of the elements in array.

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<T>(T[], Int64, T, Func<T, T, T>)

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 T GetAndAccumulate<T>(this T[] array, long index, T x, Func<T, T, T> accumulator)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

T x

Accumulator operand.

Func<T, T, T> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
T

The original value of the array element.

Type Parameters
Name Description
T

The type of the elements in array.

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<T>(T[], Int64, T)

Modifies the array element atomically.

Declaration
public static T GetAndSet<T>(this T[] array, long index, T update)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of array element to be modified.

T update

A new value to be stored as array element.

Returns
Type Description
T

Original array element before modification.

Type Parameters
Name Description
T

The type of the elements in array.

| Improve this Doc View Source

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

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

Declaration
public static T GetAndUpdate<T>(ref T value, in ValueFunc<T, T> updater)

    where T : class
Parameters
Type Name Description
T value

The value to update.

ValueFunc<T, T> updater

A side-effect-free function.

Returns
Type Description
T

The original value.

Type Parameters
Name Description
T

Type of value in the memory storage.

| Improve this Doc View Source

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

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

Declaration
public static T GetAndUpdate<T>(ref T value, Func<T, T> updater)

    where T : class
Parameters
Type Name Description
T value

The value to update.

Func<T, T> updater

A side-effect-free function.

Returns
Type Description
T

The original value.

Type Parameters
Name Description
T

Type of value in the memory storage.

| Improve this Doc View Source

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

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

Declaration
public static T GetAndUpdate<T>(this T[] array, long index, in ValueFunc<T, T> updater)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

ValueFunc<T, T> updater

A side-effect-free function.

Returns
Type Description
T

The original value of the array element.

Type Parameters
Name Description
T

The type of elements in the array.

| Improve this Doc View Source

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

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

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

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Func<T, T> updater

A side-effect-free function.

Returns
Type Description
T

The original value of the array element.

Type Parameters
Name Description
T

The type of the elements in array.

| Improve this Doc View Source

SetAndGet<T>(T[], Int64, T)

Modifies the array element atomically.

Declaration
public static T SetAndGet<T>(this T[] array, long index, T update)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of array element to be modified.

T update

A new value to be stored as array element.

Returns
Type Description
T

The array element after modification.

Type Parameters
Name Description
T

The type of the elements in array.

| Improve this Doc View Source

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

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

Declaration
public static T UpdateAndGet<T>(ref T value, in ValueFunc<T, T> updater)

    where T : class
Parameters
Type Name Description
T value

The value to update.

ValueFunc<T, T> updater

A side-effect-free function.

Returns
Type Description
T

The updated value.

Type Parameters
Name Description
T

Type of value in the memory storage.

| Improve this Doc View Source

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

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

Declaration
public static T UpdateAndGet<T>(ref T value, Func<T, T> updater)

    where T : class
Parameters
Type Name Description
T value

The value to update.

Func<T, T> updater

A side-effect-free function.

Returns
Type Description
T

The updated value.

Type Parameters
Name Description
T

Type of value in the memory storage.

| Improve this Doc View Source

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

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

Declaration
public static T UpdateAndGet<T>(this T[] array, long index, in ValueFunc<T, T> updater)

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

ValueFunc<T, T> updater

A side-effect-free function.

Returns
Type Description
T

The updated value.

Type Parameters
Name Description
T

The type of the elements in array.

| Improve this Doc View Source

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

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

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

    where T : class
Parameters
Type Name Description
T[] array

The array to be modified.

Int64 index

The index of the array element to be modified.

Func<T, T> updater

A side-effect-free function.

Returns
Type Description
T

The updated value.

Type Parameters
Name Description
T

The type of the elements in array.

| Improve this Doc View Source

VolatileRead<T>(T[], Int64)

Performs volatile read of the array element.

Declaration
public static T VolatileRead<T>(this T[] array, long index)

    where T : class
Parameters
Type Name Description
T[] array

The array to read from.

Int64 index

The array element index.

Returns
Type Description
T

The array element.

Type Parameters
Name Description
T

The type of the elements in array.

| Improve this Doc View Source

VolatileWrite<T>(T[], Int64, T)

Performs volatile write to the array element.

Declaration
public static void VolatileWrite<T>(this T[] array, long index, T element)

    where T : class
Parameters
Type Name Description
T[] array

The array to write into.

Int64 index

The array element index.

T element

The new value of the array element.

Type Parameters
Name Description
T

The type of the elements in array.

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