Provides atomic access to non-primitive data type.
Namespace: DotNext.Threading Assembly: DotNext.dll Syntaxpublic struct Atomic<T> : IStrongBox, ICloneable where T : struct
Type Parameters Name Description T
The type of the value to be accessible in atomic manner.
Properties | Edit this page View Source ValueGets or sets value atomically.
Declarationpublic T Value { get; set; }
Property Value Methods | Edit this page View Source AccumulateAndGet(in T, Accumulator, out T)
Atomically updates the stored value with the results of applying the given function to the current and given values, returning the original value.
Declarationpublic void AccumulateAndGet(in T x, Atomic<T>.Accumulator accumulator, out T result)
Parameters Type Name Description T x
Accumulator operand.
Atomic<T>.Accumulator accumulatorA side-effect-free function of two arguments.
T resultThe updated value.
Remarks Exceptions | Edit this page View Source Clone()Clones this container atomically.
Declaration Returns Type Description Atomic<T>The cloned container.
| Edit this page View Source CompareAndSet(delegate*<in T, in T, bool>, in T, in T)Atomically sets the stored value to the given updated value if the current value == the expected value.
Declaration[CLSCompliant(false)]
public bool CompareAndSet(delegate*<in T, in T, bool> comparer, in T expected, in T update)
Parameters Type Name Description delegate*<in T, in T, bool> comparer
The function representing comparison logic.
T expectedThe expected value.
T updateThe new value.
Returns Type Description booltrue if successful. false return indicates that the actual value was not equal to the expected value.
| Edit this page View Source CompareAndSet(Func<T, T, bool>, in T, in T)Atomically sets the stored value to the given updated value if the current value == the expected value.
Declarationpublic bool CompareAndSet(Func<T, T, bool> comparer, in T expected, in T update)
Parameters Type Name Description Func<T, T, bool> comparer
The function representing comparison logic.
T expectedThe expected value.
T updateThe new value.
Returns Type Description booltrue if successful. false return indicates that the actual value was not equal to the expected value.
| Edit this page View Source CompareAndSet(in T, in T)Atomically sets the stored value to the given updated value if the current value == the expected value.
Declarationpublic bool CompareAndSet(in T expected, in T update)
Parameters Type Name Description T expected
The expected value.
T updateThe new value.
Returns Type Description booltrue if successful. false return indicates that the actual value was not equal to the expected value.
| Edit this page View Source CompareExchange(delegate*<in T, in T, bool>, in T, in T, out T)Compares two values of type T
for equality and, if they are equal, replaces the stored value.
[CLSCompliant(false)]
public bool CompareExchange(delegate*<in T, in T, bool> comparer, in T update, in T expected, out T result)
Parameters Type Name Description delegate*<in T, in T, bool> comparer
The function representing comparison logic.
T updateThe value that replaces the stored value if the comparison results in equality.
T expectedThe value that is compared to the stored value.
T resultThe origin value stored in this container before modification.
Returns Type Description booltrue if the current value is replaced by update
; otherwise, false.
Compares two values of type T
for equality and, if they are equal, replaces the stored value.
public bool CompareExchange(Func<T, T, bool> comparer, in T update, in T expected, out T result)
Parameters Type Name Description Func<T, T, bool> comparer
The function representing comparison logic.
T updateThe value that replaces the stored value if the comparison results in equality.
T expectedThe value that is compared to the stored value.
T resultThe origin value stored in this container before modification.
Returns Type Description booltrue if the current value is replaced by update
; otherwise, false.
Compares two values of type T
for bitwise equality and, if they are equal, replaces the stored value.
public bool CompareExchange(in T update, in T expected, out T result)
Parameters Type Name Description T update
The value that replaces the stored value if the comparison results in equality.
T expectedThe value that is compared to the stored value.
T resultThe origin value stored in this container before modification.
Returns Type Description booltrue if the current value is replaced by update
; otherwise, false.
Sets a value stored in this container to a specified value and returns the original value, as an atomic operation.
Declarationpublic void Exchange(in T update, out T previous)
Parameters Type Name Description T update
The value that replaces the stored value.
T previousThe original stored value before modification.
| Edit this page View Source GetAndAccumulate(in T, Accumulator, out T)Atomically updates the stored value with the results of applying the given function to the current and given values, returning the updated value.
Declarationpublic void GetAndAccumulate(in T x, Atomic<T>.Accumulator accumulator, out T result)
Parameters Type Name Description T x
Accumulator operand.
Atomic<T>.Accumulator accumulatorA side-effect-free function of two arguments.
T resultThe original value.
Remarks Exceptions | Edit this page View Source GetAndUpdate(Updater, out T)Atomically updates the stored value with the results of applying the given function, returning the original value.
Declarationpublic void GetAndUpdate(Atomic<T>.Updater updater, out T result)
Parameters Type Name Description Atomic<T>.Updater updater
A side-effect-free function.
T resultThe original value.
Exceptions | Edit this page View Source Read(out T)Performs atomic read.
Declarationpublic void Read(out T result)
Parameters Type Name Description T result
The result of atomic read.
| Edit this page View Source Swap(ref Atomic<T>)Swaps the value stored in this container and the given value atomically.
Declarationpublic void Swap(ref Atomic<T> other)
Parameters Type Name Description Atomic<T> other
The container for the value.
| Edit this page View Source Swap(ref T)Swaps the value stored in this container and the given value atomically.
Declarationpublic void Swap(ref T other)
Parameters Type Name Description T other
The managed pointer to the value to swap.
| Edit this page View Source ToString()Converts the stored value into string atomically.
Declarationpublic override string? ToString()
Returns Type Description string
The string returned from ToString() method called on the stored value.
Overrides | Edit this page View Source UpdateAndGet(Updater, out T)Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declarationpublic void UpdateAndGet(Atomic<T>.Updater updater, out T result)
Parameters Type Name Description Atomic<T>.Updater updater
A side-effect-free function.
T resultThe updated value.
Exceptions | Edit this page View Source Write(in T)Performs atomic write.
Declarationpublic void Write(in T newValue)
Parameters Type Name Description T newValue
The value to be stored into this container.
Implements Extension MethodsRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4