Package org.eclipse.jetty.util
Class AtomicBiInteger
java.lang.Object
java.lang.Number
java.util.concurrent.atomic.AtomicLong
org.eclipse.jetty.util.AtomicBiInteger
- All Implemented Interfaces:
Serializable
An AtomicLong with additional methods to treat it as two hi/lo integers.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int deltaHi, int deltaLo) Atomically adds the given deltas to the current hi and lo values.int
addAndGetHi
(int delta) Atomically adds the given delta to the current hi value, returning the updated hi value.int
addAndGetLo
(int delta) Atomically adds the given delta to the current lo value, returning the updated lo value.boolean
compareAndSet
(int expectHi, int hi, int expectLo, int lo) Atomically sets the hi and lo values to the given updated values only if the current hi and lo values==
the expected hi and lo values.boolean
compareAndSet
(long encoded, int hi, int lo) Atomically sets the values to the given updated values only if the current encoded value==
the expected encoded value.boolean
compareAndSetHi
(int expectHi, int hi) Atomically sets the hi value to the given updated value only if the current value==
the expected value.boolean
compareAndSetLo
(int expectLo, int lo) Atomically sets the lo value to the given updated value only if the current value==
the expected value.static long
encode
(int hi, int lo) Encodes hi and lo values into a long.static long
encodeHi
(long encoded, int hi) Sets the hi value into the given encoded value.static long
encodeLo
(long encoded, int lo) Sets the lo value into the given encoded value.int
getAndSetHi
(int hi) Atomically sets the hi value without changing the lo value.int
getAndSetLo
(int lo) Atomically sets the lo value without changing the hi value.int
getHi()
Get the hi value.static int
getHi
(long encoded) Gets a hi value from the given encoded value.int
getLo()
Get the lo value.static int
getLo
(long encoded) Gets a lo value from the given encoded value.void
set
(int hi, int lo) Sets the hi and lo values.toString()
Methods inherited from class java.util.concurrent.atomic.AtomicLong
accumulateAndGet, addAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAcquire, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, getOpaque, getPlain, incrementAndGet, intValue, lazySet, longValue, set, setOpaque, setPlain, setRelease, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
Methods inherited from class java.lang.Number
byteValue, shortValue
-
Constructor Details
-
AtomicBiInteger
public AtomicBiInteger() -
AtomicBiInteger
public AtomicBiInteger(long encoded) -
AtomicBiInteger
public AtomicBiInteger(int hi, int lo)
-
-
Method Details
-
getHi
public int getHi()Get the hi value.- Returns:
- the hi value
-
getHi
public static int getHi(long encoded) Gets a hi value from the given encoded value.- Parameters:
encoded
- the encoded value- Returns:
- the hi value
-
getLo
public int getLo()Get the lo value.- Returns:
- the lo value
-
getLo
public static int getLo(long encoded) Gets a lo value from the given encoded value.- Parameters:
encoded
- the encoded value- Returns:
- the lo value
-
getAndSetHi
public int getAndSetHi(int hi) Atomically sets the hi value without changing the lo value.- Parameters:
hi
- the new hi value- Returns:
- the previous hi value
-
getAndSetLo
public int getAndSetLo(int lo) Atomically sets the lo value without changing the hi value.- Parameters:
lo
- the new lo value- Returns:
- the previous lo value
-
set
public void set(int hi, int lo) Sets the hi and lo values.- Parameters:
hi
- the new hi valuelo
- the new lo value
-
compareAndSetHi
public boolean compareAndSetHi(int expectHi, int hi) Atomically sets the hi value to the given updated value only if the current value
==
the expected value.Concurrent changes to the lo value result in a retry.
- Parameters:
expectHi
- the expected hi valuehi
- the new hi value- Returns:
true
if successful. False return indicates that the actual hi value was not equal to the expected hi value.
-
compareAndSetLo
public boolean compareAndSetLo(int expectLo, int lo) Atomically sets the lo value to the given updated value only if the current value
==
the expected value.Concurrent changes to the hi value result in a retry.
- Parameters:
expectLo
- the expected lo valuelo
- the new lo value- Returns:
true
if successful. False return indicates that the actual lo value was not equal to the expected lo value.
-
compareAndSet
public boolean compareAndSet(long encoded, int hi, int lo) Atomically sets the values to the given updated values only if the current encoded value==
the expected encoded value.- Parameters:
encoded
- the expected encoded valuehi
- the new hi valuelo
- the new lo value- Returns:
true
if successful. False return indicates that the actual encoded value was not equal to the expected encoded value.
-
compareAndSet
public boolean compareAndSet(int expectHi, int hi, int expectLo, int lo) Atomically sets the hi and lo values to the given updated values only if the current hi and lo values==
the expected hi and lo values.- Parameters:
expectHi
- the expected hi valuehi
- the new hi valueexpectLo
- the expected lo valuelo
- the new lo value- Returns:
true
if successful. False return indicates that the actual hi and lo values were not equal to the expected hi and lo value.
-
addAndGetHi
public int addAndGetHi(int delta) Atomically adds the given delta to the current hi value, returning the updated hi value.- Parameters:
delta
- the delta to apply- Returns:
- the updated hi value
-
addAndGetLo
public int addAndGetLo(int delta) Atomically adds the given delta to the current lo value, returning the updated lo value.- Parameters:
delta
- the delta to apply- Returns:
- the updated lo value
-
add
public void add(int deltaHi, int deltaLo) Atomically adds the given deltas to the current hi and lo values.- Parameters:
deltaHi
- the delta to apply to the hi valuedeltaLo
- the delta to apply to the lo value
-
toString
- Overrides:
toString
in classAtomicLong
-
encode
public static long encode(int hi, int lo) Encodes hi and lo values into a long.- Parameters:
hi
- the hi valuelo
- the lo value- Returns:
- the encoded value
-
encodeHi
public static long encodeHi(long encoded, int hi) Sets the hi value into the given encoded value.- Parameters:
encoded
- the encoded valuehi
- the hi value- Returns:
- the new encoded value
-
encodeLo
public static long encodeLo(long encoded, int lo) Sets the lo value into the given encoded value.- Parameters:
encoded
- the encoded valuelo
- the lo value- Returns:
- the new encoded value
-