AtomicLong
Provides lock-free atomic read/write utility for a long value. The atomic classes found in this package
are meant to replicate the java.util.concurrent.atomic package in Java by Doug Lea. The two main differences
are implicit casting back to the long data type, and the use of a non-volatile inner variable.
The internals of these classes contain wrapped usage of the System.Threading.Interlocked class, which is how we are able to provide atomic operation without the use of locks.
public AtomicLong()
Creates a new AtomicLong instance with an initial value of 0.
Creates a new AtomicLong instance with the initial value provided.
This operator allows an implicit cast from AtomicLong to long.
Atomically adds the given value to the current value.
Atomically sets the value to the given updated value if the current value == the expected value.
This method decrements the value by 1 and returns the previous value. This is the atomic
version of post-decrement.
This method decrements the value by the provided value and returns the previous value. This is the atomic
version of post-decrement.
This method returns the current value.
This method atomically adds a delta the value and returns the original value.
This method atomically sets the value and returns the original value.
This method increments the value by 1 and returns the previous value. This is the atomic
version of post-increment.
This method increments the value by the provided value and returns the previous value. This is the atomic
version of post-increment.
This method decrements the value by 1 and returns the new value. This is the atomic version
of pre-decrement.
This method increments the value by 1 and returns the new value. This is the atomic version
of pre-increment.
This method sets the current value atomically.