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.1.4.7+7f7e1f78093c99347956e09330d5d7aca1d2bdf2
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.