Show / Hide Table of Contents

Struct AtomicBoolean

Represents atomic boolean.

Implements
IEquatable<Boolean>
ISerializable
Inherited Members
Object.Equals(Object, Object)
Object.GetType()
Object.ReferenceEquals(Object, Object)
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
[Serializable]
public struct AtomicBoolean : IEquatable<bool>, ISerializable

Constructors

| Improve this Doc View Source

AtomicBoolean(Boolean)

Initializes a new atomic boolean container with initial value.

Declaration
public AtomicBoolean(bool value)
Parameters
Type Name Description
Boolean value

Initial value of the atomic boolean.

Properties

| Improve this Doc View Source

Value

Gets or sets boolean value in volatile manner.

Declaration
public bool Value { get; set; }
Property Value
Type Description
Boolean

Methods

| Improve this Doc View Source

AccumulateAndGet(Boolean, ValueFunc<Boolean, Boolean, Boolean>)

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, in ValueFunc<bool, bool, bool> accumulator)
Parameters
Type Name Description
Boolean x

Accumulator operand.

ValueFunc<Boolean, Boolean, Boolean> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Boolean

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(Boolean, Func<Boolean, Boolean, Boolean>)

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
Boolean x

Accumulator operand.

Func<Boolean, Boolean, Boolean> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Boolean

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(Boolean, Boolean)

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
Boolean expected

The expected value.

Boolean 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(Boolean, Boolean)

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
Boolean update

The new value.

Boolean expected

The expected value.

Returns
Type Description
Boolean

The original value.

| Improve this Doc View Source

Equals(Boolean)

Determines whether stored value is equal to value passed as argument.

Declaration
public bool Equals(bool other)
Parameters
Type Name Description
Boolean 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

FalseToTrue()

Atomically sets true value if the current value is false.

Declaration
public bool FalseToTrue()
Returns
Type Description
Boolean

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

| Improve this Doc View Source

GetAndAccumulate(Boolean, ValueFunc<Boolean, Boolean, Boolean>)

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, in ValueFunc<bool, bool, bool> accumulator)
Parameters
Type Name Description
Boolean x

Accumulator operand.

ValueFunc<Boolean, Boolean, Boolean> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Boolean

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(Boolean, Func<Boolean, Boolean, Boolean>)

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
Boolean x

Accumulator operand.

Func<Boolean, Boolean, Boolean> accumulator

A side-effect-free function of two arguments.

Returns
Type Description
Boolean

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

GetAndNegate()

Negates currently stored value atomically.

Declaration
public bool GetAndNegate()
Returns
Type Description
Boolean

The original value before negation.

| Improve this Doc View Source

GetAndSet(Boolean)

Modifies the current value atomically.

Declaration
public bool GetAndSet(bool update)
Parameters
Type Name Description
Boolean update

A new value to be stored into this container.

Returns
Type Description
Boolean

Original value before modification.

| Improve this Doc View Source

GetAndUpdate(ValueFunc<Boolean, Boolean>)

Atomically updates the stored value with the results of applying the given function, returning the original value.

Declaration
public bool GetAndUpdate(in ValueFunc<bool, bool> updater)
Parameters
Type Name Description
ValueFunc<Boolean, Boolean> updater

A side-effect-free function.

Returns
Type Description
Boolean

The original value.

| Improve this Doc View Source

GetAndUpdate(Func<Boolean, Boolean>)

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<Boolean, Boolean> updater

A side-effect-free function.

Returns
Type Description
Boolean

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

NegateAndGet()

Negates currently stored value atomically.

Declaration
public bool NegateAndGet()
Returns
Type Description
Boolean

Negation result.

| Improve this Doc View Source

SetAndGet(Boolean)

Modifies the current value atomically.

Declaration
public bool SetAndGet(bool update)
Parameters
Type Name Description
Boolean update

A new value to be stored into this container.

Returns
Type Description
Boolean

A new value passed as argument.

| Improve this Doc View Source

ToString()

Returns stored boolean value in the form of String.

Declaration
public override string ToString()
Returns
Type Description
String

Textual representation of stored boolean value.

Overrides
ValueType.ToString()
| Improve this Doc View Source

TrueToFalse()

Atomically sets false value if the current value is true.

Declaration
public bool TrueToFalse()
Returns
Type Description
Boolean

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

| Improve this Doc View Source

UpdateAndGet(ValueFunc<Boolean, Boolean>)

Atomically updates the stored value with the results of applying the given function, returning the updated value.

Declaration
public bool UpdateAndGet(in ValueFunc<bool, bool> updater)
Parameters
Type Name Description
ValueFunc<Boolean, Boolean> updater

A side-effect-free function.

Returns
Type Description
Boolean

The updated value.

| Improve this Doc View Source

UpdateAndGet(Func<Boolean, Boolean>)

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<Boolean, Boolean> updater

A side-effect-free function.

Returns
Type Description
Boolean

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