SystemThreadingExtensionApplyChangeOptimisticallyT(T, FuncT, T) 方法
Optimistically performs some value transformation based on some field and tries to apply it back to the field,
retrying as many times as necessary until no other thread is manipulating the same field.
命名空间: TouchSocket.Core程序集: TouchSocket.Core (在 TouchSocket.Core.dll 中) 版本:4.0.0-beta.143+5fcca7a4e70968794985dc3793adc50531308be6
public static bool ApplyChangeOptimistically<T>(
ref T hotLocation,
Func<T, T> applyChange
)
where T : class
Public Shared Function ApplyChangeOptimistically(Of T As Class) (
ByRef hotLocation As T,
applyChange As Func(Of T, T)
) As Boolean
static member ApplyChangeOptimistically :
hotLocation : 'T byref *
applyChange : Func<'T, 'T> -> bool when 'T : not struct
- hotLocation T
- The field that may be manipulated by multiple threads.
- applyChange FuncT, T
- A function that receives the unchanged value and returns the changed value.
- T
- The type of data.
Boolean if the location's value is changed by applying the result of the
applyChange function;
if the location's value remained the same because the last invocation of
applyChange returned the existing value.