Skip to content

M_CodeJam_Threading_InterlockedOperations_Initialize__1_1

Andrew Koryavchenko edited this page Jun 17, 2018 · 5 revisions

InterlockedOperations.Initialize(T) Method (T, T, T)

Initialize the value referenced by target in a thread-safe manner. The value is changed to initializedValue only if the current value is uninitializedValue.

Namespace: CodeJam.Threading
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static T Initialize<T>(
	ref T target,
	T initializedValue,
	T uninitializedValue
)
where T : class

VB

Public Shared Function Initialize(Of T As Class) ( 
	ByRef target As T,
	initializedValue As T,
	uninitializedValue As T
) As T

F#

static member Initialize : 
        target : 'T byref * 
        initializedValue : 'T * 
        uninitializedValue : 'T -> 'T  when 'T : not struct

Parameters

 

target
Type: T
Reference to the target location.
initializedValue
Type: T
The value to use if the target is currently uninitialized.
uninitializedValue
Type: T
The uninitialized value.

Type Parameters

 

T
Type of value.

Return Value

Type: T
The new value referenced by target. Note that this is nearly always more useful than the usual return from CompareExchange(T)(T, T, T) because it saves another read to target.

See Also

Reference

InterlockedOperations Class
Initialize Overload
CodeJam.Threading Namespace

Clone this wiki locally