Class AtomicReference<T>
Implementation of the java.concurrent.util AtomicReference type.
Uses Volatile internally to enforce ordering of writes without any explicit locking. .NET's strong memory on write guarantees might already enforce this ordering, but the addition of the Volatile guarantees it.
Inherited Members
Namespace: Akka.Util
Assembly: Akka.dll
Syntax
public class AtomicReference<T> where T : class
Type Parameters
| Name | Description |
|---|---|
| T | The type of object referenced by this instance. |
Constructors
| Edit this page View SourceAtomicReference()
Default constructor
Declaration
public AtomicReference()
AtomicReference(T)
Sets the initial value of this AtomicReference<T> to originalValue.
Declaration
public AtomicReference(T originalValue)
Parameters
| Type | Name | Description |
|---|---|---|
| T | originalValue | The initial value to be referenced. |
Fields
| Edit this page View SourceatomicValue
The internal field that holds the referenced value.
Declaration
protected T atomicValue
Field Value
| Type | Description |
|---|---|
| T |
Properties
| Edit this page View SourceValue
The current value of this AtomicReference<T>
Declaration
public T Value { get; set; }
Property Value
| Type | Description |
|---|---|
| T |
Methods
| Edit this page View SourceCompareAndSet(T, T)
If Value equals expected, then set the Value to
newValue.
Declaration
public bool CompareAndSet(T expected, T newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| T | expected | The value expected to be referenced currently. |
| T | newValue | The new value to reference if the current matches the expected value. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
WARNING: if you need to know the previous value, use CompareExchange(T, T) instead.
CompareExchange(T, T)
Atomically compares the current value with expected and, if they are equal,
replaces the current value with newValue.
Declaration
public T CompareExchange(T expected, T newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| T | expected | The value expected to be referenced currently. |
| T | newValue | The new value to reference if the current matches the expected value. |
Returns
| Type | Description |
|---|---|
| T | The original value that was in the atomic reference before the operation. |
GetAndSet(T)
Declaration
public T GetAndSet(T newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| T | newValue | The new value |
Returns
| Type | Description |
|---|---|
| T | The old value |
Operators
| Edit this page View Sourceimplicit operator T(AtomicReference<T>)
Performs an implicit conversion from AtomicReference<T> to T.
Declaration
public static implicit operator T(AtomicReference<T> atomicReference)
Parameters
| Type | Name | Description |
|---|---|---|
| AtomicReference<T> | atomicReference | The reference to convert |
Returns
| Type | Description |
|---|---|
| T | The result of the conversion. |
Edit this page