Gorgon
Show / Hide Table of Contents

Class GorgonStateBuilderAllocator<TB, TRs>

Common functionality for the a state fluent builder, which allows creation of state objects using GorgonStateBuilderPoolAllocator<T>.

Inheritance
object
GorgonStateBuilderCommon<TB, TRs>
GorgonStateBuilderAllocator<TB, TRs>
GorgonBlendStateBuilder
GorgonDepthStencilStateBuilder
GorgonRasterStateBuilder
Implements
IGorgonFluentBuilderAllocator<TB, TRs, IGorgonAllocator<TRs>>
IGorgonFluentBuilder<TB, TRs>
Inherited Members
GorgonStateBuilderCommon<TB, TRs>.WorkingState
GorgonStateBuilderCommon<TB, TRs>.OnCreateState()
GorgonStateBuilderCommon<TB, TRs>.OnResetTo(TRs)
GorgonStateBuilderCommon<TB, TRs>.OnClearState()
GorgonStateBuilderCommon<TB, TRs>.Build()
GorgonStateBuilderCommon<TB, TRs>.ResetTo(TRs)
GorgonStateBuilderCommon<TB, TRs>.Clear()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
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 Source

Build(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
GorgonStateBuilderCommon<TB, TRs>
GorgonStateBuilderPoolAllocator<T>
| Edit this page View Source

OnUpdate(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.

See Also
GorgonStateBuilderCommon<TB, TRs>
GorgonStateBuilderPoolAllocator<T>

Implements

IGorgonFluentBuilderAllocator<TB, TBo, TBa>
IGorgonFluentBuilder<TB, TBo>

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)

See Also

GorgonStateBuilderCommon<TB, TRs>
GorgonStateBuilderPoolAllocator<T>
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author