Kotz.ObjectPool 3.0.0

dotnet add package Kotz.ObjectPool --version 3.0.0
                    
NuGet\Install-Package Kotz.ObjectPool -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kotz.ObjectPool" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kotz.ObjectPool" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Kotz.ObjectPool" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kotz.ObjectPool --version 3.0.0
                    
#r "nuget: Kotz.ObjectPool, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kotz.ObjectPool@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kotz.ObjectPool&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Kotz.ObjectPool&version=3.0.0
                    
Install as a Cake Tool

Kotz.ObjectPool

  • Dependencies:
    • Microsoft.Extensions.ObjectPool

Defines the following types:

  • FluentObjectPool<T>: wrapper for DefaultObjectPool<T> with a more functional-oriented interface.
  • FluentObjectPool: static class containing methods to create an instance of a FluentObjectPool<T>.

How to use

// Basic usage. Let's create a pool of StringBuilders as an example.
var pool = new FluentObjectPool<StringBuilder>(() => new StringBuilder());

// Full usage. Let's create a pool of StringBuilders where:
// - StringBuilders get automatically cleared every time they are returned to the pool.
// - StringBuilders are denied entry to the pool if their string exceeds 50000 in length.
// - The pool cannot hold more than 10 StringBuilders.
var pool = new FluentObjectPool<StringBuilder>(
    () => new StringBuilder(),  // How the object should be instantiated.
    stringBuilder => stringBuilder.Clear(),  // Optional: what should be done to all objects that are returned to the pool.
    stringBuilder => stringBuilder.Length <= 50000,  // Optional: what objects should be accepted when they are returned to the pool. If false, the object is not returned to the pool and may become eligible for garbage collection.
    10  // Optional: the maximum amount of objects the pool is allowed to hold.  Set to zero to disable the limit.
);

Alternatively, you can call FluentObjectPool.Create() to create an object pool.

Product 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.0.0 199 12/30/2024
3.0.0-nightly-077 140 12/30/2024
2.3.3-nightly-076 146 10/22/2024
2.3.3-nightly-075 166 5/25/2024
2.3.2 237 5/25/2024
2.3.1 225 5/25/2024
2.3.0 209 5/24/2024
2.3.0-nightly-070 166 5/24/2024
2.3.0-nightly-069 179 5/24/2024
2.3.0-nightly-068 176 5/24/2024
2.3.0-nightly-067 169 5/24/2024
2.3.0-nightly-066 189 5/24/2024
2.3.0-nightly-065 168 5/23/2024
2.3.0-nightly-064 177 5/23/2024
2.3.0-nightly-062 178 5/16/2024
2.2.2-nightly-059 180 4/16/2024
2.2.2-nightly-058 183 4/10/2024
2.2.2-nightly-057 177 4/9/2024
2.2.2-nightly-056 179 4/4/2024
2.2.1 263 3/21/2024
Loading failed