Class ListPool

Public

Lightweight List Pool.

Handy class for pooling lists of type T.

Usage:

  • Claim a new list usingList<SomeClass> foo = ListPool<SomeClass>.Claim ();

  • Use it and do stuff with it

  • Release it withListPool<SomeClass>.Release (foo);

You do not need to clear the list before releasing it. After you have released a list, you should never use it again, if you do use it, you will mess things up quite badly in the worst case.

Since

Version 3.2

Public Static Methods

Claim ()

Claim a list.

Public Static
Claim (capacity)

Claim a list with minimum capacity Returns a pooled list if any are in the pool.

Public Static
Clear ()

Clears the pool for lists of this type.

Public Static
GetSize ()

Number of lists of this type in the pool.

Public Static
Release (list)

Releases a list and sets the variable to null.

Public Static
Release (list)

Releases a list.

Public Static
Warmup (count, size)

Makes sure the pool contains at least count pooled items with capacity size.

Public Static

Private/Protected Members

FindCandidate (pool, capacity)
Private Static
LargeThreshold
Private Static
MaxCapacitySearchLength

When requesting a list with a specified capacity, search max this many lists in the pool before giving up.

Private Static
MaxLargePoolSize
Private Static
inPool
Private Static Readonly
largePool
Private Static Readonly
pool

Internal pool.

Private Static Readonly