Struct AtomicEnum<TEnum>
Represents atomic enum value.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
[Serializable]
public struct AtomicEnum<TEnum> : IEquatable<TEnum>, ISerializable where TEnum : struct, Enum
Type Parameters
| Name | Description |
|---|---|
| TEnum | The enum type. |
Constructors
| Improve this Doc View SourceAtomicEnum(TEnum)
Initializes a new atomic boolean container with initial value.
Declaration
public AtomicEnum(TEnum value)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | value | Initial value of the atomic boolean. |
Properties
| Improve this Doc View SourceValue
Gets or sets enum value in volatile manner.
Declaration
public TEnum Value { get; set; }
Property Value
| Type | Description |
|---|---|
| TEnum |
Methods
| Improve this Doc View SourceAccumulateAndGet(TEnum, ValueFunc<TEnum, TEnum, TEnum>)
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 TEnum AccumulateAndGet(TEnum x, in ValueFunc<TEnum, TEnum, TEnum> accumulator)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | x | Accumulator operand. |
| ValueFunc<TEnum, TEnum, TEnum> | accumulator | A side-effect-free function of two arguments. |
Returns
| Type | Description |
|---|---|
| TEnum | 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(TEnum, Func<TEnum, TEnum, TEnum>)
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 TEnum AccumulateAndGet(TEnum x, Func<TEnum, TEnum, TEnum> accumulator)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | x | Accumulator operand. |
| Func<TEnum, TEnum, TEnum> | accumulator | A side-effect-free function of two arguments. |
Returns
| Type | Description |
|---|---|
| TEnum | 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(TEnum, TEnum)
Atomically sets referenced value to the given updated value if the current value == the expected value.
Declaration
public bool CompareAndSet(TEnum expected, TEnum update)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | expected | The expected value. |
| TEnum | 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(TEnum, TEnum)
Atomically sets referenced value to the given updated value if the current value == the expected value.
Declaration
public TEnum CompareExchange(TEnum update, TEnum expected)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | update | The new value. |
| TEnum | expected | The expected value. |
Returns
| Type | Description |
|---|---|
| TEnum | The original value. |
Equals(TEnum)
Determines whether stored value is equal to value passed as argument.
Declaration
public bool Equals(TEnum other)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | 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. |
Overrides
| Improve this Doc View SourceGetAndAccumulate(TEnum, ValueFunc<TEnum, TEnum, TEnum>)
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 TEnum GetAndAccumulate(TEnum x, in ValueFunc<TEnum, TEnum, TEnum> accumulator)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | x | Accumulator operand. |
| ValueFunc<TEnum, TEnum, TEnum> | accumulator | A side-effect-free function of two arguments. |
Returns
| Type | Description |
|---|---|
| TEnum | 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(TEnum, Func<TEnum, TEnum, TEnum>)
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 TEnum GetAndAccumulate(TEnum x, Func<TEnum, TEnum, TEnum> accumulator)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | x | Accumulator operand. |
| Func<TEnum, TEnum, TEnum> | accumulator | A side-effect-free function of two arguments. |
Returns
| Type | Description |
|---|---|
| TEnum | 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(TEnum)
Modifies the current value atomically.
Declaration
public TEnum GetAndSet(TEnum update)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | update | A new value to be stored into this container. |
Returns
| Type | Description |
|---|---|
| TEnum | Original value before modification. |
GetAndUpdate(ValueFunc<TEnum, TEnum>)
Atomically updates the stored value with the results of applying the given function, returning the original value.
Declaration
public TEnum GetAndUpdate(in ValueFunc<TEnum, TEnum> updater)
Parameters
| Type | Name | Description |
|---|---|---|
| ValueFunc<TEnum, TEnum> | updater | A side-effect-free function. |
Returns
| Type | Description |
|---|---|
| TEnum | The original value. |
GetAndUpdate(Func<TEnum, TEnum>)
Atomically updates the stored value with the results of applying the given function, returning the original value.
Declaration
public TEnum GetAndUpdate(Func<TEnum, TEnum> updater)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TEnum, TEnum> | updater | A side-effect-free function. |
Returns
| Type | Description |
|---|---|
| TEnum | 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. |
Overrides
| Improve this Doc View SourceSetAndGet(TEnum)
Modifies the current value atomically.
Declaration
public TEnum SetAndGet(TEnum update)
Parameters
| Type | Name | Description |
|---|---|---|
| TEnum | update | A new value to be stored into this container. |
Returns
| Type | Description |
|---|---|
| TEnum | A new value passed as argument. |
ToString()
Converts the value in this container to its textual representation.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String | The value in this container converted to string. |
Overrides
| Improve this Doc View SourceUpdateAndGet(ValueFunc<TEnum, TEnum>)
Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declaration
public TEnum UpdateAndGet(in ValueFunc<TEnum, TEnum> updater)
Parameters
| Type | Name | Description |
|---|---|---|
| ValueFunc<TEnum, TEnum> | updater | A side-effect-free function. |
Returns
| Type | Description |
|---|---|
| TEnum | The updated value. |
UpdateAndGet(Func<TEnum, TEnum>)
Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declaration
public TEnum UpdateAndGet(Func<TEnum, TEnum> updater)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TEnum, TEnum> | updater | A side-effect-free function. |
Returns
| Type | Description |
|---|---|
| TEnum | The updated value. |
Explicit Interface Implementations
| Improve this Doc View SourceISerializable.GetObjectData(SerializationInfo, StreamingContext)
Declaration
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| SerializationInfo | info | |
| StreamingContext | context |