Tandbox.ReferencePool 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Tandbox.ReferencePool --version 1.0.0
                    
NuGet\Install-Package Tandbox.ReferencePool -Version 1.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="Tandbox.ReferencePool" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tandbox.ReferencePool" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Tandbox.ReferencePool" />
                    
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 Tandbox.ReferencePool --version 1.0.0
                    
#r "nuget: Tandbox.ReferencePool, 1.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 Tandbox.ReferencePool@1.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=Tandbox.ReferencePool&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Tandbox.ReferencePool&version=1.0.0
                    
Install as a Cake Tool

ReferencePool

The ReferencePool class provides a mechanism for managing object pooling to reduce memory allocation and improve performance. It allows acquiring, releasing, adding, and removing references of specific types.

Installation

Install the latest version of the [Tandbox.ReferencePool] package from nuget:

dotnet add package Tandbox.ReferencePool

Features

  • Object Pooling: Efficiently reuse objects to minimize memory allocation overhead.
  • Type-Specific Pools: Manage pools for different types of objects.
  • Thread-Safe Operations: Ensures safe access to the pool in multi-threaded environments.
  • Statistics Tracking: Provides detailed information about the pool's usage, including counts for acquired, released, added, and removed references.

Key Components

ReferencePool

A static class that serves as the entry point for managing reference pools.

  • Acquire: Retrieve an object from the pool.
  • Release: Return an object to the pool after use.
  • Add: Preload objects into the pool.
  • Remove: Remove objects from the pool.
  • ClearAll: Clear all reference pools.

ReferenceCollection

An internal class that manages a specific type of reference.

  • Tracks usage statistics such as:
    • Unused references
    • References in use
    • Total acquired, released, added, and removed references

ReferencePoolInformation

A struct that provides detailed information about a specific reference pool.

  • Includes properties for:
    • Reference type
    • Counts for unused, in-use, acquired, released, added, and removed references

Usage

Acquiring and Releasing References

// Acquire a reference of type MyReference
var reference = ReferencePool.Acquire<MyReference>();

// Use the reference
reference.DoSomething();

// Release the reference back to the pool
ReferencePool.Release(reference);

ReferencePool

The ReferencePool class provides a mechanism for managing object pooling to reduce memory allocation and improve performance. It allows acquiring, releasing, adding, and removing references of specific types.

Features

  • Efficiently manage object pooling to minimize memory allocation overhead.
  • Support for acquiring and releasing references.
  • Ability to add and remove references dynamically.
  • Strict type checking for reference management.
  • Detailed statistics for reference pool usage.

Namespace

Tandbox.ReferencePool

Key Classes and Interfaces

  • ReferencePool: The main static class for managing reference pools.
  • IReference: Interface that all pooled objects must implement.
  • ReferencePoolInformation: Struct that provides detailed information about the state of a reference pool.

How to Use

1. Implement the IReference Interface

All objects that will be managed by the ReferencePool must implement the IReference interface. This interface requires a Clear method to reset the object's state.

public class MyReference : IReference {
    public int Value { get; set; }

    public void Clear() {
        Value = 0;
    }
}
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 was computed.  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.
  • net8.0

    • No dependencies.

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