Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 963 Bytes

File metadata and controls

45 lines (29 loc) · 963 Bytes

Net-Pools

Documentation

A pool implementation for Net objects.

Quickstart

Using the global pool is very straightforward.

MyExpensiveType instance = ObjectPool<MyExpensiveType>.Shared.Rent();

// [... execute some operations ...]

ObjectPool<MyExpensiveType>.Shared.Return(instance);

public class MyExpensiveType
{
    // [...]
}

It also supports the using pattern, value types and IDisposable:

using Lease<MyExpensiveType> lease = ObjectPool<MyExpensiveType>.Shared.RentLease();

instance = lease.Value;

// [... execute some operations ...]

public struct MyExpensiveType : IDisposable
{
    // [...]
}

And there are pools for arrays of an exact length rather than a minimum length:

using Lease<object[]> lease = ExactLengthArrayPool<object>.Shared.Rent(15);

// [... execute some operations ...]