Struct Atomic.Boolean
Represents atomic boolean.
Implements
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public struct Atomic.Boolean : IEquatable<bool>
Remarks
Initializes a new atomic boolean container with initial value.
Constructors
| Edit this page View SourceBoolean(bool)
Represents atomic boolean.
Declaration
public Boolean(bool value)
Parameters
Type | Name | Description |
---|---|---|
bool | value | Initial value of the atomic boolean. |
Remarks
Initializes a new atomic boolean container with initial value.
Properties
| Edit this page View SourceValue
Gets or sets boolean value in volatile manner.
Declaration
public bool Value { readonly get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceAccumulateAndGet(bool, Func<bool, bool, bool>)
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 bool AccumulateAndGet(bool x, Func<bool, bool, bool> accumulator)
Parameters
Type | Name | Description |
---|---|---|
bool | x | Accumulator operand. |
Func<bool, bool, bool> | accumulator | A side-effect-free function of two arguments. |
Returns
Type | Description |
---|---|
bool | 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<TAccumulator>(bool, TAccumulator)
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 bool AccumulateAndGet<TAccumulator>(bool x, TAccumulator accumulator) where TAccumulator : ISupplier<bool, bool, bool>
Parameters
Type | Name | Description |
---|---|---|
bool | x | Accumulator operand. |
TAccumulator | accumulator | A side-effect-free function of two arguments. |
Returns
Type | Description |
---|---|
bool | The updated value. |
Type Parameters
Name | Description |
---|---|
TAccumulator | The type implementing accumulator. |
Remarks
The function is applied with the current value as its first argument, and the given update as the second argument.
CompareAndSet(bool, bool)
Atomically sets referenced value to the given updated value if the current value == the expected value.
Declaration
public bool CompareAndSet(bool expected, bool update)
Parameters
Type | Name | Description |
---|---|---|
bool | expected | The expected value. |
bool | update | The new value. |
Returns
Type | Description |
---|---|
bool | true if successful. false return indicates that the actual value was not equal to the expected value. |
CompareExchange(bool, bool)
Atomically sets referenced value to the given updated value if the current value == the expected value.
Declaration
public bool CompareExchange(bool update, bool expected)
Parameters
Type | Name | Description |
---|---|---|
bool | update | The new value. |
bool | expected | The expected value. |
Returns
Type | Description |
---|---|
bool | The original value. |
Equals(bool)
Determines whether stored value is equal to value passed as argument.
Declaration
public readonly bool Equals(bool other)
Parameters
Type | Name | Description |
---|---|---|
bool | other | Other value to compare. |
Returns
Type | Description |
---|---|
bool | 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 readonly bool Equals(object? other)
Parameters
Type | Name | Description |
---|---|---|
object | other | Other value to compare. |
Returns
Type | Description |
---|---|
bool | true, if stored value is equal to other value; otherwise, false. |
Overrides
| Edit this page View SourceFalseToTrue()
Declaration
public bool FalseToTrue()
Returns
Type | Description |
---|---|
bool | true if current value is modified successfully; otherwise, false. |
GetAndAccumulate(bool, Func<bool, bool, bool>)
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 bool GetAndAccumulate(bool x, Func<bool, bool, bool> accumulator)
Parameters
Type | Name | Description |
---|---|---|
bool | x | Accumulator operand. |
Func<bool, bool, bool> | accumulator | A side-effect-free function of two arguments. |
Returns
Type | Description |
---|---|
bool | 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<TAccumulator>(bool, TAccumulator)
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 bool GetAndAccumulate<TAccumulator>(bool x, TAccumulator accumulator) where TAccumulator : ISupplier<bool, bool, bool>
Parameters
Type | Name | Description |
---|---|---|
bool | x | Accumulator operand. |
TAccumulator | accumulator | A side-effect-free function of two arguments. |
Returns
Type | Description |
---|---|
bool | The original value. |
Type Parameters
Name | Description |
---|---|
TAccumulator | The type implementing accumulator. |
Remarks
The function is applied with the current value as its first argument, and the given update as the second argument.
GetAndNegate()
Negates currently stored value atomically.
Declaration
public bool GetAndNegate()
Returns
Type | Description |
---|---|
bool | The original value before negation. |
GetAndSet(bool)
Modifies the current value atomically.
Declaration
public bool GetAndSet(bool update)
Parameters
Type | Name | Description |
---|---|---|
bool | update | A new value to be stored into this container. |
Returns
Type | Description |
---|---|
bool | Original value before modification. |
GetAndUpdate(Func<bool, bool>)
Atomically updates the stored value with the results of applying the given function, returning the original value.
Declaration
public bool GetAndUpdate(Func<bool, bool> updater)
Parameters
Type | Name | Description |
---|---|---|
Func<bool, bool> | updater | A side-effect-free function. |
Returns
Type | Description |
---|---|
bool | The original value. |
GetAndUpdate<TUpdater>(TUpdater)
Atomically updates the stored value with the results of applying the given function, returning the original value.
Declaration
public bool GetAndUpdate<TUpdater>(TUpdater updater) where TUpdater : ISupplier<bool, bool>
Parameters
Type | Name | Description |
---|---|---|
TUpdater | updater | A side-effect-free function. |
Returns
Type | Description |
---|---|
bool | The original value. |
Type Parameters
Name | Description |
---|---|
TUpdater | The type implementing updater. |
GetHashCode()
Computes hash code for the stored value.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
int | The hash code of the stored boolean value. |
Overrides
| Edit this page View SourceNegateAndGet()
Negates currently stored value atomically.
Declaration
public bool NegateAndGet()
Returns
Type | Description |
---|---|
bool | Negation result. |
SetAndGet(bool)
Modifies the current value atomically.
Declaration
public bool SetAndGet(bool update)
Parameters
Type | Name | Description |
---|---|---|
bool | update | A new value to be stored into this container. |
Returns
Type | Description |
---|---|
bool | A new value passed as argument. |
ToString()
Returns stored boolean value in the form of string.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
string | Textual representation of stored boolean value. |
Overrides
| Edit this page View SourceTrueToFalse()
Declaration
public bool TrueToFalse()
Returns
Type | Description |
---|---|
bool | true if current value is modified successfully; otherwise, false. |
UpdateAndGet(Func<bool, bool>)
Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declaration
public bool UpdateAndGet(Func<bool, bool> updater)
Parameters
Type | Name | Description |
---|---|---|
Func<bool, bool> | updater | A side-effect-free function. |
Returns
Type | Description |
---|---|
bool | The updated value. |
UpdateAndGet<TUpdater>(TUpdater)
Atomically updates the stored value with the results of applying the given function, returning the updated value.
Declaration
public bool UpdateAndGet<TUpdater>(TUpdater updater) where TUpdater : ISupplier<bool, bool>
Parameters
Type | Name | Description |
---|---|---|
TUpdater | updater | A side-effect-free function. |
Returns
Type | Description |
---|---|
bool | The updated value. |
Type Parameters
Name | Description |
---|---|
TUpdater | The type implementing updater. |