Kotz.ObjectPool 2.2.2-nightly-057

This is a prerelease version of Kotz.ObjectPool.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Kotz.ObjectPool --version 2.2.2-nightly-057                
NuGet\Install-Package Kotz.ObjectPool -Version 2.2.2-nightly-057                
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="2.2.2-nightly-057" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kotz.ObjectPool --version 2.2.2-nightly-057                
#r "nuget: Kotz.ObjectPool, 2.2.2-nightly-057"                
#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.
// Install Kotz.ObjectPool as a Cake Addin
#addin nuget:?package=Kotz.ObjectPool&version=2.2.2-nightly-057&prerelease

// Install Kotz.ObjectPool as a Cake Tool
#tool nuget:?package=Kotz.ObjectPool&version=2.2.2-nightly-057&prerelease                

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 net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Kotz.ObjectPool:

Package Downloads
Kotz.Utilities

Provides utility types and methods for common tasks. This is a metapackage that includes all Kotz utility packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.3.3-nightly-075 71 5/25/2024
2.3.2 84 5/25/2024
2.3.1 85 5/25/2024
2.3.0 91 5/24/2024
2.3.0-nightly-070 77 5/24/2024
2.3.0-nightly-069 77 5/24/2024
2.3.0-nightly-068 75 5/24/2024
2.3.0-nightly-067 77 5/24/2024
2.3.0-nightly-066 83 5/24/2024
2.3.0-nightly-065 71 5/23/2024
2.3.0-nightly-064 75 5/23/2024
2.3.0-nightly-062 81 5/16/2024
2.2.2-nightly-059 92 4/16/2024
2.2.2-nightly-058 63 4/10/2024
2.2.2-nightly-057 69 4/9/2024
2.2.2-nightly-056 65 4/4/2024
2.2.1 116 3/21/2024
2.2.1-nightly-054 66 3/21/2024
2.2.1-nightly-053 80 3/20/2024
2.2.1-nightly-051 56 3/16/2024
2.2.0 186 12/17/2023
2.2.0-nightly-049 78 12/23/2023
2.2.0-nightly-048 91 12/17/2023
2.2.0-nightly-042 94 9/23/2023
2.2.0-nightly-041 89 9/23/2023
2.2.0-nightly-039 78 9/23/2023
2.1.1 428 9/23/2023
2.1.1-nightly-038 90 9/16/2023
2.1.1-nightly-037 103 8/19/2023
2.1.0 161 8/11/2023
2.1.0-nightly-036 134 8/11/2023
2.1.0-nightly-035 134 5/20/2023
2.1.0-nightly-034 160 1/9/2023
2.1.0-nightly-033 142 12/2/2022
2.0.0 380 11/23/2022
2.0.0-nightly-028 137 11/3/2022
2.0.0-nightly-027 168 10/19/2022
2.0.0-nightly-026 140 10/9/2022
2.0.0-nightly-025 155 10/8/2022
2.0.0-nightly-023 163 9/25/2022
2.0.0-nightly-021 155 9/23/2022