Struct AtomicEnum<E>
Represents atomic enum value.
Implements
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public struct AtomicEnum<E> : IEquatable<E>, ISerializable where E : struct, Enum
Type Parameters
Name | Description |
---|---|
E |
Constructors
| Improve this Doc View SourceAtomicEnum(E)
Initializes a new atomic boolean container with initial value.
Declaration
public AtomicEnum(E value)
Parameters
Type | Name | Description |
---|---|---|
E | value | Initial value of the atomic boolean. |
Properties
| Improve this Doc View SourceValue
Gets or sets enum value in volatile manner.
Declaration
public E Value { get; set; }
Property Value
Type | Description |
---|---|
E |
Methods
| Improve this Doc View SourceAccumulateAndGet(E, Func<E, E, E>)
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 E AccumulateAndGet(E x, Func<E, E, E> accumulator)
Parameters
Type | Name | Description |
---|---|---|
E | x | Accumulator operand. |
DotNext.Func<E, E, E> | accumulator | A side-effect-free function of two arguments |
Returns
Type | Description |
---|---|
E | 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(E, ValueFunc<E, E, E>)
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 E AccumulateAndGet(E x, in ValueFunc<E, E, E> accumulator)
Parameters
Type | Name | Description |
---|---|---|
E | x | Accumulator operand. |
ValueFunc<E, E, E> | accumulator | A side-effect-free function of two arguments |
Returns
Type | Description |
---|---|
E | The updated value. |
Remarks
The function is applied with the current value as its first argument, and the given update as the second argument.
CompareAndSet(E, E)
Atomically sets referenced value to the given updated value if the current value == the expected value.
Declaration
public bool CompareAndSet(E expected, E update)
Parameters
Type | Name | Description |
---|---|---|
E | expected | The expected value. |
E | 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(E, E)
Atomically sets referenced value to the given updated value if the current value == the expected value.
Declaration
public E CompareExchange(E update, E expected)
Parameters
Type | Name | Description |
---|---|---|
E | update | The new value. |
E | expected | The expected value. |
Returns
Type | Description |
---|---|
E | The original value. |
Equals(E)
Determines whether stored value is equal to value passed as argument.
Declaration
public bool Equals(E other)
Parameters
Type | Name | Description |
---|---|---|
E | other | Other value to compare. |
Returns
Type | Description |
---|---|
Boolean | true, if stored value is equal to other value; otherwise, false. |
Equals(Object)
Determines whether stored value is equal to value as the passed argument.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | Other value to compare. |
Returns
Type | Description |
---|---|
Boolean | true, if stored value is equal to other value; otherwise, false. |
GetAndAccumulate(E, Func<E, E, E>)
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 E GetAndAccumulate(E x, Func<E, E, E> accumulator)
Parameters
Type | Name | Description |
---|---|---|
E | x | Accumulator operand. |
DotNext.Func<E, E, E> | accumulator | A side-effect-free function of two arguments |
Returns
Type | Description |
---|---|
E | 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(E, ValueFunc<E, E, E>)
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 E GetAndAccumulate(E x, in ValueFunc<E, E, E> accumulator)
Parameters
Type | Name | Description |
---|---|---|
E | x | Accumulator operand. |
ValueFunc<E, E, E> | accumulator | A side-effect-free function of two arguments |
Returns
Type | Description |
---|---|
E | The original value. |
Remarks
The function is applied with the current value as its first argument, and the given update as the second argument.
GetAndSet(E)
Modifies the current value atomically.
Declaration
public E GetAndSet(E update)
Parameters
Type | Name | Description |
---|---|---|
E | update | A new value to be stored into this container. |
Returns
Type | Description |
---|---|
E | Original value before modification. |
GetAndUpdate(Func<E, E>)
Atomically updates the stored value with the results of applying the given function, returning the original value.
Declaration
public E GetAndUpdate(Func<E, E> updater)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Func<E, E> | updater | A side-effect-free function |
Returns
Type | Description |
---|---|
E | The original value. |
GetAndUpdate(ValueFunc<E, E>)
Atomically updates the stored value with the results of applying the given function, returning the original value.
Declaration
public E GetAndUpdate(in ValueFunc<E, E> updater)
Parameters
Type | Name | Description |
---|---|---|
ValueFunc<E, E> | updater | A side-effect-free function |
Returns
Type | Description |
---|---|
E | The original value. |
GetHashCode()
Computes hash code for the stored value.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code of the stored boolean value. |
SetAndGet(E)
Modifies the current value atomically.
Declaration
public E SetAndGet(E update)
Parameters
Type | Name | Description |
---|---|---|
E | update | A new value to be stored into this container. |
Returns
Type | Description |
---|---|
E | A new value passed as argument. |
UpdateAndGet(Func<E, E>)
Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declaration
public E UpdateAndGet(Func<E, E> updater)
Parameters
Type | Name | Description |
---|---|---|
DotNext.Func<E, E> | updater | A side-effect-free function |
Returns
Type | Description |
---|---|
E | The updated value. |
UpdateAndGet(ValueFunc<E, E>)
Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declaration
public E UpdateAndGet(in ValueFunc<E, E> updater)
Parameters
Type | Name | Description |
---|---|---|
ValueFunc<E, E> | updater | A side-effect-free function |
Returns
Type | Description |
---|---|
E | The updated value. |