Struct DeferredInitializer
A type of object that guarantees thread-safe, on-demand initialization. An initialization action is only executed once.
Inherited Members
System.ValueType.Equals(System.Object)
System.ValueType.GetHashCode()
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Namespace: Flame.Collections
Assembly: Flame.dll
Syntax
public struct DeferredInitializer
Properties
| Improve this Doc View SourceHasInitialized
Gets a boolean that determines whether the initializer has run or not.
Declaration
public bool HasInitialized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
| Improve this Doc 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 |
---|---|---|
System.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. |
System.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 |
---|---|
System.Boolean |
|