Class GorgonStateBuilderAllocator<TB, TRs>
Common functionality for the a state fluent builder, which allows creation of state objects using GorgonStateBuilderPoolAllocator<T>.
Implements
Inherited Members
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public abstract class GorgonStateBuilderAllocator<TB, TRs> : GorgonStateBuilderCommon<TB, TRs>, IGorgonFluentBuilderAllocator<TB, TRs, IGorgonAllocator<TRs>>, IGorgonFluentBuilder<TB, TRs> where TB : GorgonStateBuilderCommon<TB, TRs> where TRs : class, IEquatable<TRs>
Type Parameters
Name | Description |
---|---|
TB | The type of builder. |
TRs | The type of state. |
Remarks
This is the same as the GorgonStateBuilderCommon<TB, TRs> base class, only it exposes functionality to provide object allocation via a GorgonStateBuilderPoolAllocator<T>. The provides efficient reuse of objects to minimize garbage collection and improve performance. All state builder classes will descend from this unless they implement their own caching strategy.
Methods
| Edit this page View SourceBuild(IGorgonAllocator<TRs>)
Function to return the object.
Declaration
public TRs Build(IGorgonAllocator<TRs> allocator)
Parameters
Type | Name | Description |
---|---|---|
IGorgonAllocator<TRs> | allocator | The allocator used to create an instance of the object |
Returns
Type | Description |
---|---|
TRs | 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.
See Also
| Edit this page View SourceOnUpdate(TRs)
Function to update the properties of the state, allocated from an allocator, from the working copy.
Declaration
protected abstract void OnUpdate(TRs state)
Parameters
Type | Name | Description |
---|---|---|
TRs | state | The state to update. |