Soenneker.Atomics.NullableBools
4.0.42
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Atomics.NullableBools --version 4.0.42
NuGet\Install-Package Soenneker.Atomics.NullableBools -Version 4.0.42
<PackageReference Include="Soenneker.Atomics.NullableBools" Version="4.0.42" />
<PackageVersion Include="Soenneker.Atomics.NullableBools" Version="4.0.42" />
<PackageReference Include="Soenneker.Atomics.NullableBools" />
paket add Soenneker.Atomics.NullableBools --version 4.0.42
#r "nuget: Soenneker.Atomics.NullableBools, 4.0.42"
#:package Soenneker.Atomics.NullableBools@4.0.42
#addin nuget:?package=Soenneker.Atomics.NullableBools&version=4.0.42
#tool nuget:?package=Soenneker.Atomics.NullableBools&version=4.0.42
Soenneker.Atomics.NullableBools
A lightweight atomic tri-state flag implemented on top of an inline ValueAtomicInt. Backing values: -1 = null / unknown 0 = false 1 = true.
Install
dotnet add package Soenneker.Atomics.NullableBools
Usage
The null state is useful for a value that has not been determined yet. TrySet lets one caller publish the first result:
using Soenneker.Atomics.NullableBools;
var availability = new AtomicNullableBool();
if (availability.TrySet(await ProbeAvailability()))
{
// This caller published the transition from unknown to known.
}
bool? result = availability.Value;
availability.Reset();
GetValueOrFalse and GetValueOrTrue provide explicit fallback policies without changing the stored state.
Prefer the nullable Value, Set, TrySet, and Reset members in application code. Read, Write, and TryCompareExchange expose the raw representation (-1, 0, 1) and do not validate supplied integers; invalid raw values can produce misleading boolean and string results.
What you get
AtomicNullableBool— A lightweight atomic tri-state flag implemented on top of an inlineValueAtomicInt. Backing values:-1= null / unknown0= false1= true.
API at a glance
| API | What it does | Result / important behavior |
|---|---|---|
AtomicNullableBool.HasValue |
Gets a value indicating whether the current state is non-null. | Gets a value indicating whether the current state is non-null. |
AtomicNullableBool.Value |
Gets or sets the current value as a nullable boolean. | Gets or sets the current value as a nullable boolean. |
AtomicNullableBool.Read() |
Reads the raw backing state. | -1 (null), 0 (false), or 1 (true). |
AtomicNullableBool.GetValueOrFalse() |
Gets the value, treating null/unknown as false. |
true if gets the value, treating null/unknown as; otherwise, false. |
AtomicNullableBool.GetValueOrTrue() |
Gets the value, treating null/unknown as true. |
true if gets the value, treating null/unknown as; otherwise, false. |
AtomicNullableBool.Set(value) |
Sets the state to true or false. |
Returns no value; the requested change is complete when the method returns. |
AtomicNullableBool.TrySet(value) |
Attempts to set the state to true or false only if the current state is null/unknown. |
true if the requested update was applied; otherwise, false. |
AtomicNullableBool.TryCompareExchange(newState, expected) |
Attempts to transition the state from expected to newState. |
true if the requested update was applied; otherwise, false. |
AtomicNullableBool.Reset() |
Resets the state to null/unknown. |
Returns no value; the requested change is complete when the method returns. |
AtomicNullableBool.ToString() |
Returns a string representation of the current state. | Returns string. |
Important behavior
AtomicNullableBool: Reads establish acquire semantics and writes establish release semantics. This is a mutable reference type. Use as a private field and avoid exposing the instance publicly unless you want shared, aliasable state.AtomicNullableBool.Write(state): Callers must only provide valid values:-1,0, or1.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Soenneker.Atomics.ValueInts (>= 4.0.23)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.43 | 0 | 8/30/2026 |
| 4.0.42 | 0 | 8/29/2026 |
| 4.0.41 | 22 | 8/29/2026 |
| 4.0.40 | 28 | 8/29/2026 |
| 4.0.39 | 111 | 7/28/2026 |
| 4.0.38 | 101 | 7/28/2026 |
| 4.0.37 | 103 | 7/16/2026 |
| 4.0.36 | 110 | 7/16/2026 |
| 4.0.35 | 116 | 6/19/2026 |
| 4.0.34 | 112 | 6/19/2026 |
| 4.0.33 | 122 | 6/5/2026 |
| 4.0.32 | 114 | 6/5/2026 |
| 4.0.31 | 115 | 6/5/2026 |
| 4.0.30 | 129 | 4/22/2026 |
| 4.0.29 | 114 | 4/22/2026 |
| 4.0.27 | 156 | 3/13/2026 |
| 4.0.26 | 140 | 3/12/2026 |
| 4.0.25 | 137 | 3/12/2026 |
| 4.0.24 | 144 | 3/12/2026 |
| 4.0.23 | 135 | 3/12/2026 |
Improve README documentation