com.sun.btrace
Class BTraceUtils.Atomic

java.lang.Object
  extended by com.sun.btrace.BTraceUtils.Atomic
Enclosing class:
BTraceUtils

public static class BTraceUtils.Atomic
extends java.lang.Object


Constructor Summary
BTraceUtils.Atomic()
           
 
Method Summary
static int addAndGet(java.util.concurrent.atomic.AtomicInteger ai, int delta)
          Atomically adds the given value to the current value.
static long addAndGet(java.util.concurrent.atomic.AtomicLong al, long delta)
          Atomically adds the given value to the current value.
static boolean compareAndSet(java.util.concurrent.atomic.AtomicInteger ai, int expect, int update)
          Atomically sets the value of given AtomitInteger to the given updated value if the current value == the expected value.
static boolean compareAndSet(java.util.concurrent.atomic.AtomicLong al, long expect, long update)
          Atomically sets the value to the given updated value if the current value == the expected value.
static int decrementAndGet(java.util.concurrent.atomic.AtomicInteger ai)
          Atomically decrements by one the current value of given AtomicInteger.
static long decrementAndGet(java.util.concurrent.atomic.AtomicLong al)
          Atomically decrements by one the current value.
static int get(java.util.concurrent.atomic.AtomicInteger ai)
          Gets the current value of the given AtomicInteger.
static long get(java.util.concurrent.atomic.AtomicLong al)
          Gets the current value the given AtomicLong.
static int getAndAdd(java.util.concurrent.atomic.AtomicInteger ai, int delta)
          Atomically adds the given value to the current value.
static long getAndAdd(java.util.concurrent.atomic.AtomicLong al, long delta)
          Atomically adds the given value to the current value.
static int getAndDecrement(java.util.concurrent.atomic.AtomicInteger ai)
          Atomically decrements by one the current value of given AtomicInteger.
static long getAndDecrement(java.util.concurrent.atomic.AtomicLong al)
          Atomically decrements by one the current value.
static int getAndIncrement(java.util.concurrent.atomic.AtomicInteger ai)
          Atomically increments by one the current value of given AtomicInteger.
static long getAndIncrement(java.util.concurrent.atomic.AtomicLong al)
          Atomically increments by one the current value.
static int getAndSet(java.util.concurrent.atomic.AtomicInteger ai, int newValue)
          Atomically sets to the given value and returns the old value.
static long getAndSet(java.util.concurrent.atomic.AtomicLong al, long newValue)
          Atomically sets to the given value and returns the old value.
static int incrementAndGet(java.util.concurrent.atomic.AtomicInteger ai)
          Atomically increments by one the current value of given AtomicInteger.
static long incrementAndGet(java.util.concurrent.atomic.AtomicLong al)
          Atomically increments by one the current value.
static void lazySet(java.util.concurrent.atomic.AtomicInteger ai, int newValue)
          Eventually sets to the given value to the given AtomicInteger.
static void lazySet(java.util.concurrent.atomic.AtomicLong al, long newValue)
          Eventually sets to the given value to the given AtomicLong.
static java.util.concurrent.atomic.AtomicInteger newAtomicInteger(int initialValue)
          Creates a new AtomicInteger with the given initial value.
static java.util.concurrent.atomic.AtomicLong newAtomicLong(long initialValue)
          Creates a new AtomicLong with the given initial value.
static void set(java.util.concurrent.atomic.AtomicInteger ai, int newValue)
          Sets to the given value to the given AtomicInteger.
static void set(java.util.concurrent.atomic.AtomicLong al, long newValue)
          Sets to the given value.
static boolean weakCompareAndSet(java.util.concurrent.atomic.AtomicInteger ai, int expect, int update)
          Atomically sets the value to the given updated value if the current value == the expected value.
static boolean weakCompareAndSet(java.util.concurrent.atomic.AtomicLong al, long expect, long update)
          Atomically sets the value to the given updated value if the current value == the expected value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTraceUtils.Atomic

public BTraceUtils.Atomic()
Method Detail

newAtomicInteger

public static java.util.concurrent.atomic.AtomicInteger newAtomicInteger(int initialValue)
Creates a new AtomicInteger with the given initial value.

Parameters:
initialValue - the initial value

get

public static int get(java.util.concurrent.atomic.AtomicInteger ai)
Gets the current value of the given AtomicInteger.

Parameters:
ai - AtomicInteger whose value is returned.
Returns:
the current value

set

public static void set(java.util.concurrent.atomic.AtomicInteger ai,
                       int newValue)
Sets to the given value to the given AtomicInteger.

Parameters:
ai - AtomicInteger whose value is set.
newValue - the new value

lazySet

public static void lazySet(java.util.concurrent.atomic.AtomicInteger ai,
                           int newValue)
Eventually sets to the given value to the given AtomicInteger.

Parameters:
ai - AtomicInteger whose value is lazily set.
newValue - the new value

compareAndSet

public static boolean compareAndSet(java.util.concurrent.atomic.AtomicInteger ai,
                                    int expect,
                                    int update)
Atomically sets the value of given AtomitInteger to the given updated value if the current value == the expected value.

Parameters:
ai - AtomicInteger whose value is compared and set.
expect - the expected value
update - the new value
Returns:
true if successful. False return indicates that the actual value was not equal to the expected value.

weakCompareAndSet

public static boolean weakCompareAndSet(java.util.concurrent.atomic.AtomicInteger ai,
                                        int expect,
                                        int update)
Atomically sets the value to the given updated value if the current value == the expected value.

May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet.

Parameters:
ai - AtomicInteger whose value is weakly compared and set.
expect - the expected value
update - the new value
Returns:
true if successful.

getAndIncrement

public static int getAndIncrement(java.util.concurrent.atomic.AtomicInteger ai)
Atomically increments by one the current value of given AtomicInteger.

Parameters:
ai - AtomicInteger that is incremented.
Returns:
the previous value

getAndDecrement

public static int getAndDecrement(java.util.concurrent.atomic.AtomicInteger ai)
Atomically decrements by one the current value of given AtomicInteger.

Parameters:
ai - AtomicInteger that is decremented.
Returns:
the previous value

incrementAndGet

public static int incrementAndGet(java.util.concurrent.atomic.AtomicInteger ai)
Atomically increments by one the current value of given AtomicInteger.

Parameters:
ai - AtomicInteger that is incremented.
Returns:
the updated value

decrementAndGet

public static int decrementAndGet(java.util.concurrent.atomic.AtomicInteger ai)
Atomically decrements by one the current value of given AtomicInteger.

Parameters:
ai - AtomicInteger whose value is decremented.
Returns:
the updated value

getAndAdd

public static int getAndAdd(java.util.concurrent.atomic.AtomicInteger ai,
                            int delta)
Atomically adds the given value to the current value.

Parameters:
ai - AtomicInteger whose value is added to.
delta - the value to add
Returns:
the previous value

addAndGet

public static int addAndGet(java.util.concurrent.atomic.AtomicInteger ai,
                            int delta)
Atomically adds the given value to the current value.

Parameters:
ai - AtomicInteger whose value is added to.
delta - the value to add
Returns:
the updated value

getAndSet

public static int getAndSet(java.util.concurrent.atomic.AtomicInteger ai,
                            int newValue)
Atomically sets to the given value and returns the old value.

Parameters:
ai - AtomicInteger whose value is set.
newValue - the new value
Returns:
the previous value

newAtomicLong

public static java.util.concurrent.atomic.AtomicLong newAtomicLong(long initialValue)
Creates a new AtomicLong with the given initial value.

Parameters:
initialValue - the initial value

get

public static long get(java.util.concurrent.atomic.AtomicLong al)
Gets the current value the given AtomicLong.

Parameters:
al - AtomicLong whose value is returned.
Returns:
the current value

set

public static void set(java.util.concurrent.atomic.AtomicLong al,
                       long newValue)
Sets to the given value.

Parameters:
al - AtomicLong whose value is set.
newValue - the new value

lazySet

public static void lazySet(java.util.concurrent.atomic.AtomicLong al,
                           long newValue)
Eventually sets to the given value to the given AtomicLong.

Parameters:
al - AtomicLong whose value is set.
newValue - the new value

compareAndSet

public static boolean compareAndSet(java.util.concurrent.atomic.AtomicLong al,
                                    long expect,
                                    long update)
Atomically sets the value to the given updated value if the current value == the expected value.

Parameters:
al - AtomicLong whose value is compared and set.
expect - the expected value
update - the new value
Returns:
true if successful. False return indicates that the actual value was not equal to the expected value.

weakCompareAndSet

public static boolean weakCompareAndSet(java.util.concurrent.atomic.AtomicLong al,
                                        long expect,
                                        long update)
Atomically sets the value to the given updated value if the current value == the expected value.

May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet.

Parameters:
al - AtomicLong whose value is compared and set.
expect - the expected value
update - the new value
Returns:
true if successful.

getAndIncrement

public static long getAndIncrement(java.util.concurrent.atomic.AtomicLong al)
Atomically increments by one the current value.

Parameters:
al - AtomicLong whose value is incremented.
Returns:
the previous value

getAndDecrement

public static long getAndDecrement(java.util.concurrent.atomic.AtomicLong al)
Atomically decrements by one the current value.

Parameters:
al - AtomicLong whose value is decremented.
Returns:
the previous value

incrementAndGet

public static long incrementAndGet(java.util.concurrent.atomic.AtomicLong al)
Atomically increments by one the current value.

Parameters:
al - AtomicLong whose value is incremented.
Returns:
the updated value

decrementAndGet

public static long decrementAndGet(java.util.concurrent.atomic.AtomicLong al)
Atomically decrements by one the current value.

Parameters:
al - AtomicLong whose value is decremented.
Returns:
the updated value

getAndAdd

public static long getAndAdd(java.util.concurrent.atomic.AtomicLong al,
                             long delta)
Atomically adds the given value to the current value.

Parameters:
al - AtomicLong whose value is added to.
delta - the value to add
Returns:
the previous value

addAndGet

public static long addAndGet(java.util.concurrent.atomic.AtomicLong al,
                             long delta)
Atomically adds the given value to the current value.

Parameters:
al - AtomicLong whose value is added to
delta - the value to add
Returns:
the updated value

getAndSet

public static long getAndSet(java.util.concurrent.atomic.AtomicLong al,
                             long newValue)
Atomically sets to the given value and returns the old value.

Parameters:
al - AtomicLong that is set.
newValue - the new value
Returns:
the previous value