Class InterlockedSpin
Provides various convenience lock-free atomic "spin" operations.
Namespace: Singulink.Threading
Assembly: Singulink.Threading.dll
Syntax
public static class InterlockedSpin
Remarks
The methods provided here try to perform the requested operation without a lock and keep retrying if a competing thread modifies the value first. These methods are fully compatible with Interlocked and Volatile methods on the same locations and can be used in conjunction with them as needed.
Methods
Name | Description |
---|---|
Exchange<T>(ref T, Func<T, T>) | Replaces a value with a new value generated by a factory function. |
Exchange<T>(ref T, out T, Func<T, T>) | Replaces a value with a new value generated by a factory function. |
TryDecrementToMin(ref int, int) | Attempts to decrement the specified value up to a maximum value. |
TryDecrementToMin(ref int, int, out int) | Attempts to decrement the specified value up to a maximum value. |
TryIncrementToMax(ref int, int) | Attempts to increment the specified value up to a maximum value. |
TryIncrementToMax(ref int, int, out int) | Attempts to increment the specified value up to a maximum value. |