Show / Hide Table of Contents

Class InterlockedCounter

Implementation of AtomicCounter based on .NET System.Threading.Interlocked class.

Inheritance
object
AtomicCounter
InterlockedCounter
Inherited Members
AtomicCounter.Increment()
AtomicCounter.Increment(long)
AtomicCounter.PostIncrement()
AtomicCounter.PostIncrement(long)
AtomicCounter.Decrement()
AtomicCounter.Decrement(long)
AtomicCounter.PostDecrement()
AtomicCounter.PostDecrement(long)
AtomicCounter.ToString()
AtomicCounter.NewAtomicCounter()
AtomicCounter.NewAtomicCounter(long)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
public class InterlockedCounter : AtomicCounter

Fields

m_counter

The actual counter value.

Declaration
protected long m_counter
Field Value
Type Description
long

Methods

Adjust(long)

Adjust the value of the counter by the specified amount, and return the new value.

Declaration
protected override long Adjust(long c)
Parameters
Type Name Description
long c

The amount to adjust the counter by.

Returns
Type Description
long

The new value, after the adjustment has been made.

Overrides
AtomicCounter.Adjust(long)

GetCount()

Return the current value of the counter.

Declaration
public override long GetCount()
Returns
Type Description
long

The current value.

Overrides
AtomicCounter.GetCount()

PostAdjust(long)

Adjust the value of the counter by the specified amount, and return the old value.

Declaration
protected override long PostAdjust(long c)
Parameters
Type Name Description
long c

The amount to adjust the counter by.

Returns
Type Description
long

The old value, prior to the adjustment having been made.

Overrides
AtomicCounter.PostAdjust(long)

SetCount(long)

Update the current value, and return the previous value.

Declaration
public override long SetCount(long newValue)
Parameters
Type Name Description
long newValue

The new value.

Returns
Type Description
long

The previous value just before the update went through.

Overrides
AtomicCounter.SetCount(long)

SetCount(long, long)

Update the current value, only if it is equal to the assumed value.

Declaration
public override bool SetCount(long assumedValue, long newValue)
Parameters
Type Name Description
long assumedValue

The assumed old value.

long newValue

The new value.

Returns
Type Description
bool

true if the value was updated, false otherwise.

Overrides
AtomicCounter.SetCount(long, long)

See Also

AtomicCounter
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.