Soenneker.Atomics.ValueNullableBools
4.0.33
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Atomics.ValueNullableBools --version 4.0.33
NuGet\Install-Package Soenneker.Atomics.ValueNullableBools -Version 4.0.33
<PackageReference Include="Soenneker.Atomics.ValueNullableBools" Version="4.0.33" />
<PackageVersion Include="Soenneker.Atomics.ValueNullableBools" Version="4.0.33" />
<PackageReference Include="Soenneker.Atomics.ValueNullableBools" />
paket add Soenneker.Atomics.ValueNullableBools --version 4.0.33
#r "nuget: Soenneker.Atomics.ValueNullableBools, 4.0.33"
#:package Soenneker.Atomics.ValueNullableBools@4.0.33
#addin nuget:?package=Soenneker.Atomics.ValueNullableBools&version=4.0.33
#tool nuget:?package=Soenneker.Atomics.ValueNullableBools&version=4.0.33
Soenneker.Atomics.ValueNullableBools
A lightweight, allocation-free 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.ValueNullableBools
Usage
using Soenneker.Atomics.ValueNullableBools;
public sealed class FeatureProbe
{
private ValueAtomicNullableBool _supported;
public bool Publish(bool result) => _supported.TrySet(result);
public bool? Read() => _supported.Value;
public void Invalidate() => _supported.Reset();
}
The default value represents null/unknown. TrySet atomically lets one caller publish the first known boolean. GetValueOrFalse and GetValueOrTrue read with an explicit fallback without changing the stored state.
This is a mutable struct and must remain in stable field storage. Passing it by value or returning it from a property creates independent tri-state state. Use the reference-type AtomicNullableBool when the wrapper itself must be shared.
Prefer the nullable API in application code. Raw Write and TryCompareExchange accept integer states without validation; only -1, 0, and 1 have defined meaning.
What you get
ValueAtomicNullableBool— A lightweight, allocation-free 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 |
|---|---|---|
ValueAtomicNullableBool.HasValue |
Gets a value indicating whether the current state is non-null. | Gets a value indicating whether the current state is non-null. |
ValueAtomicNullableBool.Value |
Gets the current value as a nullable boolean. | Gets the current value as a nullable boolean. |
ValueAtomicNullableBool.Read() |
Reads the raw backing state. | -1 (null), 0 (false), or 1 (true). |
ValueAtomicNullableBool.GetValueOrFalse() |
Gets the value, treating null/unknown as false. |
true if gets the value, treating null/unknown as; otherwise, false. |
ValueAtomicNullableBool.GetValueOrTrue() |
Gets the value, treating null/unknown as true. |
true if gets the value, treating null/unknown as; otherwise, false. |
ValueAtomicNullableBool.Set(value) |
Sets the state to true or false. |
Returns no value; the requested change is complete when the method returns. |
ValueAtomicNullableBool.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. |
ValueAtomicNullableBool.TryCompareExchange(newState, expected) |
Attempts to transition the state from expected to newState. |
true if the requested update was applied; otherwise, false. |
ValueAtomicNullableBool.Reset() |
Resets the state to null/unknown. |
Returns no value; the requested change is complete when the method returns. |
ValueAtomicNullableBool.ToString() |
Returns a string representation of the current state. | Returns string. |
Important behavior
ValueAtomicNullableBool: Reads establish acquire semantics and writes establish release semantics. This is a mutablestructintended for use as a private field or inline synchronization primitive. Avoid copying this type or exposing it publicly.ValueAtomicNullableBool.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 (2)
Showing the top 2 NuGet packages that depend on Soenneker.Atomics.ValueNullableBools:
| Package | Downloads |
|---|---|
|
Soenneker.Utils.Runtime
Detects the current operating system, common hosting environments, and container execution. |
|
|
Soenneker.Utils.Environment
A utility library for useful environment related functionality |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.34 | 123,217 | 8/30/2026 |
| 4.0.33 | 7,705 | 8/29/2026 |
| 4.0.32 | 89 | 8/29/2026 |
| 4.0.31 | 87 | 8/29/2026 |
| 4.0.30 | 307,417 | 7/28/2026 |
| 4.0.29 | 105 | 7/28/2026 |
| 4.0.28 | 133,043 | 7/16/2026 |
| 4.0.27 | 108 | 7/16/2026 |
| 4.0.26 | 163,914 | 6/19/2026 |
| 4.0.25 | 3,625 | 6/18/2026 |
| 4.0.24 | 175,637 | 6/5/2026 |
| 4.0.23 | 3,364 | 6/5/2026 |
| 4.0.22 | 116 | 6/5/2026 |
| 4.0.21 | 220,222 | 4/22/2026 |
| 4.0.20 | 140 | 4/22/2026 |
| 4.0.18 | 173,135 | 3/12/2026 |
| 4.0.17 | 536 | 3/12/2026 |
| 4.0.16 | 143 | 3/12/2026 |
| 4.0.15 | 160 | 3/12/2026 |
| 4.0.14 | 2,089 | 3/12/2026 |
Improve README documentation