Interface IGorgonFluentBuilderAllocator<TB, TBo, TBa>
An interface that defines a standard set of functionality for a builder pattern object.
Inherited Members
Namespace: Gorgon.Core
Assembly: Gorgon.Core.dll
Syntax
public interface IGorgonFluentBuilderAllocator<out TB, TBo, in TBa> : IGorgonFluentBuilder<TB, TBo> where TB : class where TBo : class where TBa : IGorgonAllocator<TBo>
Type Parameters
Name | Description |
---|---|
TB | The type of builder. Used to return a fluent interface for the builder. |
TBo | The type of object produced by the builder. |
TBa | The type of optional allocator to use for building objects. Must derive from GorgonRingPool<T>. |
Remarks
This interface is used to define a fluent builder pattern for creating objects.
Unlike the IGorgonFluentBuilder<TB, TBo> interface, this one defines an allocator type TBa
.
Methods
| Edit this page View SourceBuild(TBa)
Function to return the object.
Declaration
TBo Build(TBa allocator)
Parameters
Type | Name | Description |
---|---|---|
TBa | allocator | The allocator used to create an instance of the object |
Returns
Type | Description |
---|---|
TBo | The object created or updated by this builder. |
Remarks
Using an allocator
can provide different strategies when building objects. If omitted, the object will be created using the standard new keyword.
A custom allocator can be beneficial because it allows us to use a pool for allocating the objects, and thus allows for recycling of objects. This keeps the garbage collector happy by keeping objects around for as long as we need them, instead of creating objects that can potentially end up in the large object heap or in Gen 2.