Struct DeferredInitializer
A type of object that guarantees thread-safe, on-demand initialization. An initialization action is only executed once.
Inherited Members
Namespace: Flame.Collections
Assembly: Flame.dll
Syntax
public struct DeferredInitializer
Properties
| Edit this page View SourceHasInitialized
Gets a boolean that determines whether the initializer has run or not.
Declaration
public bool HasInitialized { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
| Edit this page View SourceCreate(Action)
Creates a deferred initializer that executes a particular initialization action once.
Declaration
public static DeferredInitializer Create(Action initializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | initializer | The initializer to run once. |
Returns
| Type | Description |
|---|---|
| DeferredInitializer | A deferred initializer. |
Create<T>(T, Action<T>)
Creates a deferred initializer that runs a particular initializer once on a particular value.
Declaration
public static DeferredInitializer Create<T>(T instance, Action<T> initializer)
Parameters
| Type | Name | Description |
|---|---|---|
| T | instance | A value to initialize. |
| Action<T> | initializer | The initializer to run. |
Returns
| Type | Description |
|---|---|
| DeferredInitializer | A deferred initializer. |
Type Parameters
| Name | Description |
|---|---|
| T |
Initialize()
Ensures that the initializer has run. This will run the initializer if it has not run before and do nothing otherwise.
Declaration
public bool Initialize()
Returns
| Type | Description |
|---|---|
| bool |
|