Soenneker.Utils.LazyBools
11.0.35
Prefix Reserved
dotnet add package Soenneker.Utils.LazyBools --version 11.0.35
NuGet\Install-Package Soenneker.Utils.LazyBools -Version 11.0.35
<PackageReference Include="Soenneker.Utils.LazyBools" Version="11.0.35" />
<PackageVersion Include="Soenneker.Utils.LazyBools" Version="11.0.35" />
<PackageReference Include="Soenneker.Utils.LazyBools" />
paket add Soenneker.Utils.LazyBools --version 11.0.35
#r "nuget: Soenneker.Utils.LazyBools, 11.0.35"
#:package Soenneker.Utils.LazyBools@11.0.35
#addin nuget:?package=Soenneker.Utils.LazyBools&version=11.0.35
#tool nuget:?package=Soenneker.Utils.LazyBools&version=11.0.35
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 | 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. net11.0 is compatible. |
-
net10.0
- No dependencies.
-
net11.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 |
|---|---|---|
| 11.0.35 | 0 | 11/30/2026 |
| 11.0.34 | 6,371 | 11/18/2026 |
| 11.0.33 | 63,216 | 11/11/2026 |
| 11.0.32 | 51,750 | 11/2/2026 |
| 11.0.31 | 30,055 | 10/26/2026 |
| 4.0.30 | 72,371 | 10/15/2026 |
| 4.0.29 | 7,814 | 10/14/2026 |
| 4.0.24 | 10,217 | 10/13/2026 |
| 4.0.23 | 105 | 10/12/2026 |
| 4.0.22 | 5,636 | 10/11/2026 |
| 4.0.21 | 129,771 | 9/24/2026 |
| 4.0.20 | 38,304 | 9/15/2026 |
| 4.0.19 | 43,690 | 9/12/2026 |
| 4.0.18 | 139,132 | 8/30/2026 |
| 4.0.17 | 6,861 | 8/29/2026 |
| 4.0.16 | 141 | 8/29/2026 |
| 4.0.15 | 197,862 | 7/28/2026 |
| 4.0.14 | 99,371 | 7/16/2026 |
| 4.0.13 | 144,839 | 6/19/2026 |
| 4.0.12 | 119,946 | 6/5/2026 |
Update soenneker/nuget-resilient-publish action to v5 (#78)
Automatically merged