org.terracotta.toolkit.concurrent.atomic
Interface ToolkitAtomicLong

All Superinterfaces:
Destroyable, ToolkitObject

public interface ToolkitAtomicLong
extends Destroyable, ToolkitObject

A toolkit atomic long that can be used to maintain counters in the toolkit in a thread-safe manner across the toolkit implementation platform.

Consult the Toolkit class level docs for more info on behavior regarding destroy.


Method Summary
 long addAndGet(long delta)
          Atomically add the supplied value to the current value.
 byte byteValue()
          Number.byteValue()
 boolean compareAndSet(long expect, long update)
          Atomically set the value to the new value if the current value == the given value.
 long decrementAndGet()
          Atomically decrement the current value by one.
 double doubleValue()
          Number.doubleValue()
 float floatValue()
          Number.floatValue()
 long get()
          Get the current value.
 long getAndAdd(long delta)
          Atomically add the supplied value to the current value.
 long getAndDecrement()
          Atomically decrement the current value.
 long getAndIncrement()
          Atomically increment the current value.
 long getAndSet(long newValue)
          Atomically: set to the given value and return the previous value.
 long incrementAndGet()
          Atomically increment the current value
 int intValue()
          Number.intValue()
 long longValue()
          Number.longValue()
 void set(long newValue)
          Set to the given value
 short shortValue()
          Number.shortValue()
 
Methods inherited from interface org.terracotta.toolkit.object.Destroyable
destroy, isDestroyed
 
Methods inherited from interface org.terracotta.toolkit.object.ToolkitObject
getName
 

Method Detail

addAndGet

long addAndGet(long delta)
Atomically add the supplied value to the current value.

Parameters:
delta - the value to add
Returns:
the new value

compareAndSet

boolean compareAndSet(long expect,
                      long update)
Atomically set the value to the new value if the current value == the given value.

Parameters:
expect - the expected value
update - the new value
Returns:
true if successful, false if the comparison failed

decrementAndGet

long decrementAndGet()
Atomically decrement the current value by one.

Returns:
the new value

get

long get()
Get the current value.

Returns:
the current value

getAndAdd

long getAndAdd(long delta)
Atomically add the supplied value to the current value.

Parameters:
delta - the value to add
Returns:
the previous value

getAndDecrement

long getAndDecrement()
Atomically decrement the current value.

Returns:
the previous value

getAndIncrement

long getAndIncrement()
Atomically increment the current value.

Returns:
the previous value

getAndSet

long getAndSet(long newValue)
Atomically: set to the given value and return the previous value.

Parameters:
newValue - the new value
Returns:
the previous value

incrementAndGet

long incrementAndGet()
Atomically increment the current value

Returns:
the new value

set

void set(long newValue)
Set to the given value

Parameters:
newValue - the new value

byteValue

byte byteValue()
Number.byteValue()


shortValue

short shortValue()
Number.shortValue()


intValue

int intValue()
Number.intValue()


longValue

long longValue()
Number.longValue()


floatValue

float floatValue()
Number.floatValue()


doubleValue

double doubleValue()
Number.doubleValue()



Copyright © 2014 Terracotta, Inc.. All Rights Reserved.