Table of Contents

Class PooledObjectBuffer<T>

Namespace
CodeProject.ObjectPool.Core
Assembly
CodeProject.ObjectPool.dll

A buffer into which pooled objects are stored. This buffer mostly behaves like a queue, even if that behavior is not strictly respected in order to maximize performance.

public sealed class PooledObjectBuffer<T> : IEnumerable<T>, IEnumerable where T : PooledObject

Type Parameters

T

The type of the object that which will be managed by the pool. The pooled object have to be a sub-class of PooledObject.

Inheritance
PooledObjectBuffer<T>
Implements
Inherited Members

Properties

Capacity

The maximum capacity of this buffer.

public int Capacity { get; }

Property Value

int

Count

The number of objects stored in this buffer.

public int Count { get; }

Property Value

int

Methods

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

An enumerator that can be used to iterate through the collection.

Resize(int)

Resizes the buffer so that it fits to given capacity. If new capacity is smaller than current capacity, then exceeding items are returned.

public IList<T?> Resize(int newCapacity)

Parameters

newCapacity int

The new capacity of this buffer.

Returns

IList<T>

All exceeding items.

TryDequeue(out T?)

Tries to dequeue an object from the buffer.

public bool TryDequeue(out T? pooledObject)

Parameters

pooledObject T

Output pooled object.

Returns

bool

True if pooledObject has a value, false otherwise.

TryEnqueue(T)

Tries to enqueue given object into the buffer.

public bool TryEnqueue(T pooledObject)

Parameters

pooledObject T

Input pooled object.

Returns

bool

True if there was enough space to enqueue given object, false otherwise.

TryRemove(T)

Tries to remove given object from the buffer.

public bool TryRemove(T pooledObject)

Parameters

pooledObject T

Pooled object to be removed.

Returns

bool

True if pooledObject has been removed, false otherwise.