Soenneker.Utils.LazyBools
4.0.20
Prefix Reserved
dotnet add package Soenneker.Utils.LazyBools --version 4.0.20
NuGet\Install-Package Soenneker.Utils.LazyBools -Version 4.0.20
<PackageReference Include="Soenneker.Utils.LazyBools" Version="4.0.20" />
<PackageVersion Include="Soenneker.Utils.LazyBools" Version="4.0.20" />
<PackageReference Include="Soenneker.Utils.LazyBools" />
paket add Soenneker.Utils.LazyBools --version 4.0.20
#r "nuget: Soenneker.Utils.LazyBools, 4.0.20"
#:package Soenneker.Utils.LazyBools@4.0.20
#addin nuget:?package=Soenneker.Utils.LazyBools&version=4.0.20
#tool nuget:?package=Soenneker.Utils.LazyBools&version=4.0.20
Soenneker.Utils.LazyBools
A tiny, allocation-free, publication-only lazy initializer for bools.
Installation
dotnet add package Soenneker.Utils.LazyBools
Quick start
using Soenneker.Utils.LazyBools;
public sealed class Feature
{
private int _isAvailableState;
public bool IsAvailable => LazyBoolUtil.GetOrInit(
ref _isAvailableState,
threadSafe: true,
this,
static feature => feature.CheckAvailability());
private bool CheckAvailability() => /* expensive check */ true;
}
Call the static LazyBoolUtil methods directly; no dependency-injection registration is required.
Semantics
GetOrInit stores its state in the caller-provided int: 0 is uninitialized, 1 is false, and
2 is true. Initialize the field to zero and do not use or mutate it for anything else.
With threadSafe: true, initialization is publication-only. Concurrent callers can run compute
more than once, but one result is published and returned to every caller. Use a side-effect-free
or otherwise concurrency-safe delegate. If the delegate throws before a value is published, the
state remains uninitialized and a later call can retry.
Use threadSafe: false only when calls are single-threaded or protected by external
synchronization. That path avoids the interlocked publication operation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Utils.LazyBools:
| Package | Downloads |
|---|---|
|
Soenneker.Reflection.Cache
The fastest .NET Reflection cache |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.20 | 16,464 | 9/15/2026 |
| 4.0.19 | 43,068 | 9/12/2026 |
| 4.0.18 | 137,386 | 8/30/2026 |
| 4.0.17 | 6,651 | 8/29/2026 |
| 4.0.16 | 105 | 8/29/2026 |
| 4.0.15 | 193,128 | 7/28/2026 |
| 4.0.14 | 98,581 | 7/16/2026 |
| 4.0.13 | 132,097 | 6/19/2026 |
| 4.0.12 | 118,878 | 6/5/2026 |
| 4.0.11 | 199,861 | 4/23/2026 |
| 4.0.10 | 119,409 | 3/14/2026 |
| 4.0.5 | 47,088 | 3/10/2026 |
| 4.0.4 | 22,731 | 3/9/2026 |
| 4.0.3 | 230 | 3/9/2026 |
| 4.0.2 | 49,724 | 3/4/2026 |
| 4.0.1 | 51,608 | 2/23/2026 |
Update dependency dotnet-sdk to v10.0.401 (#51)
Automatically merged