ReusableResourceHolder<TResource> Struct

Definition

Holds a reference to a shared resource allocated by a ReusableResourceStoreBase, and releases the resource back to the ReusableResourceStoreBase upon dispose.

generic <typename TResource>
 where TResource : classpublic value class ReusableResourceHolder : IDisposable
public struct ReusableResourceHolder<TResource> : IDisposable where TResource : class
type ReusableResourceHolder<'Resource (requires 'Resource : null)> = struct
    interface IDisposable
Public Structure ReusableResourceHolder(Of TResource)
Implements IDisposable

Type Parameters

TResource

The type of resource stored in the holder.

Inheritance
ReusableResourceHolder<TResource>
Implements

Remarks

This MUST be a value type for ReusableResourceStore to be efficient. Returning a reference type would require an allocation on each call to Acquire, which would defeat the memory allocation savings of using ReusableResourceStore and ReusableResourceHolder in the first place.

Properties

Resource

Gets the resource stored by this resource holder. After this object is disposed, returns null.

Methods

Dispose()

Disposes of the resource, releasing it back to the ReusableResourceStore it came from.

Applies to