Show / Hide Table of Contents

Struct AtomicEnum<TEnum>

Represents atomic enum value.

Implements
IEquatable<TEnum>
ISerializable
Inherited Members
Object.Equals(Object, Object)
Object.GetType()
Object.ReferenceEquals(Object, Object)
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 Source

AtomicEnum(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 Source

Value

Gets or sets enum value in volatile manner.

Declaration
public TEnum Value { get; set; }
Property Value
Type Description
TEnum

Methods

| Improve this Doc View Source

AccumulateAndGet(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
ValueType.Equals(Object)
| Improve this Doc View Source

GetAndAccumulate(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
ValueType.GetHashCode()
| Improve this Doc View Source

SetAndGet(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.

| Improve this Doc View Source

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
ValueType.ToString()
| Improve this Doc View Source

UpdateAndGet(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.

| Improve this Doc View Source

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 Source

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Declaration
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
SerializationInfo info
StreamingContext context

Implements

System.IEquatable<T>
System.Runtime.Serialization.ISerializable

Extension Methods

Sequence.Skip<TEnumerator, T>(ref TEnumerator, Int32)
ExpressionBuilder.Const<T>(T)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX