Show / Hide Table of Contents

Struct Atomic.Boolean

Represents atomic boolean.

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

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

Value

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 Source

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

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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
ValueType.Equals(object)
| Edit this page View Source

FalseToTrue()

Atomically sets true value if the current value is false.

Declaration
public bool FalseToTrue()
Returns
Type Description
bool

true if current value is modified successfully; otherwise, false.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

GetAndNegate()

Negates currently stored value atomically.

Declaration
public bool GetAndNegate()
Returns
Type Description
bool

The original value before negation.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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

NegateAndGet()

Negates currently stored value atomically.

Declaration
public bool NegateAndGet()
Returns
Type Description
bool

Negation result.

| Edit this page View Source

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.

| Edit this page View Source

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

TrueToFalse()

Atomically sets false value if the current value is true.

Declaration
public bool TrueToFalse()
Returns
Type Description
bool

true if current value is modified successfully; otherwise, false.

| Edit this page View Source

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.

| Edit this page View Source

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.

Implements

IEquatable<T>

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
Collection.ToAsyncEnumerator<TEnumerator, T>(TEnumerator, CancellationToken)
Collection.ToClassicEnumerator<TEnumerator, T>(TEnumerator)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
ExpressionBuilder.Const<T>(T)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾