Class PooledObject<T>
Struct holding a pooled object, exposing RAII capabilities to return the object to the pool upon disposal.
Inheritance
Namespace: System.Memory
Assembly: Nuqleon.Memory.dll
Syntax
public sealed class PooledObject<T> : ValueType, IDisposable, IEquatable<PooledObject<T>> where T : class
Type Parameters
Name | Description |
---|---|
T | Type of the object. |
Constructors
PooledObject(ObjectPoolBase<T>)
Allocates a new object from the pool and stores it in the wrapper instance.
Declaration
public PooledObject(ObjectPoolBase<T> pool)
Parameters
Type | Name | Description |
---|---|---|
ObjectPoolBase<T> | pool | Pool to obtain an object from. |
PooledObject(ObjectPoolBase<T>, Func<ObjectPoolBase<T>, T>, Action<ObjectPoolBase<T>, T>)
Allocates a new object from the pool and stores it in the wrapper instance.
Declaration
public PooledObject(ObjectPoolBase<T> pool, Func<ObjectPoolBase<T>, T> allocator, Action<ObjectPoolBase<T>, T> releaser)
Parameters
Type | Name | Description |
---|---|---|
ObjectPoolBase<T> | pool | Pool to obtain an object from. |
System.Func<ObjectPoolBase<T>, T> | allocator | Custom allocator function. |
System.Action<ObjectPoolBase<T>, T> | releaser | Custom releaser function. |
Properties
Object
Gets the pooled object instance.
Declaration
public T Object { get; }
Property Value
Type | Description |
---|---|
T | Pooled object instance, or null if the object has been freed. |
Methods
Dispose()
Disposes the pooled object holder, returning the pooled object to its pool.
Declaration
public void Dispose()
Equals(PooledObject<T>)
Checks if the current object is equal to the specified object.
Declaration
public bool Equals(PooledObject<T> other)
Parameters
Type | Name | Description |
---|---|---|
PooledObject<T> | other | The object to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | true if the objects are equal; otherwise, false. |
Equals(Object)
Checks if the current object is equal to the specified object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | true if the objects are equal; otherwise, false. |
GetHashCode()
Gets a hash code for the current object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for the current object. |
Operators
Equality(PooledObject<T>, PooledObject<T>)
Checks if the two objects are equal.
Declaration
public static bool operator ==(PooledObject<T> left, PooledObject<T> right)
Parameters
Type | Name | Description |
---|---|---|
PooledObject<T> | left | The first object to compare. |
PooledObject<T> | right | The second object to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if both objects are equal; otherwise, false. |
Inequality(PooledObject<T>, PooledObject<T>)
Checks if the two objects are not equal.
Declaration
public static bool operator !=(PooledObject<T> left, PooledObject<T> right)
Parameters
Type | Name | Description |
---|---|---|
PooledObject<T> | left | The first object to compare. |
PooledObject<T> | right | The second object to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if both objects are not equal; otherwise, false. |