Class AtomicInteger
- java.lang.Object
-
- com.avpkit.ferry.AtomicInteger
-
public class AtomicInteger extends java.lang.Object
Internal only. Atomic Integer represents Integers than can be updated
atomically from native code.
This object is NOT meant to be called from Java (in fact, that'd be stupid
since you'd just be calling from native code back into Java). It's
here so that native code inside a JVM can have access to portable
thread-safe objects.
And that said, this method is really only Atomic if running inside a
Java JVM (or other virtual machine that can provide the functionality).
If running in a standalone C++ program there
is no current guarantee of Atomicity.
The object just forwards to the Java object:
{java.util.concurrent.atomic.AtomicInteger}
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanswigCMemOwnInternal Only.
-
Constructor Summary
Constructors Modifier Constructor Description AtomicInteger()AtomicInteger(int arg0)protectedAtomicInteger(long cPtr, boolean cMemoryOwn)Internal Only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddAndGet(int arg0)booleancompareAndSet(int expected, int update)Compare the current value to expected, and if
they are equal, set the current value to update.intdecrementAndGet()voiddelete()Releases any underlying native memory and marks this object as invalid.booleanequals(java.lang.Object obj)Compares two values, returning true if the underlying objects in native code are the same object.protected voidfinalize()Internal Only.intget()intgetAndAdd(int arg0)intgetAndDecrement()intgetAndIncrement()intgetAndSet(int arg0)static longgetCPtr(AtomicInteger obj)Internal Only.longgetMyCPtr()Internal Only.inthashCode()Get a hashable value for this object.intincrementAndGet()booleanisAtomic()voidset(int arg0)
-
-
-
Field Detail
-
swigCMemOwn
protected boolean swigCMemOwn
Internal Only.
-
-
Constructor Detail
-
AtomicInteger
protected AtomicInteger(long cPtr, boolean cMemoryOwn)
Internal Only. DO NOT USE: Do not allocate this method using new. Not part of public API.Unfortunately this constructor is public because the internal implementation needs it to be, but do not pass in values to this method as you may end up crashing the virtual machine.
- Parameters:
cPtr- A C pointer to direct memory; did we mention don't call this.cMemoryOwn- I'm not even going to tell you. Stop it. Go away.
-
AtomicInteger
public AtomicInteger()
-
AtomicInteger
public AtomicInteger(int arg0)
-
-
Method Detail
-
getCPtr
public static long getCPtr(AtomicInteger obj)
Internal Only. Not part of public API. Get the raw value of the native object that obj is proxying for.- Parameters:
obj- The java proxy object for a native object.- Returns:
- The raw pointer obj is proxying for.
-
getMyCPtr
public long getMyCPtr()
Internal Only. Not part of public API. Get the raw value of the native object that we're proxying for.- Returns:
- The raw pointer we're proxying for.
-
equals
public boolean equals(java.lang.Object obj)
Compares two values, returning true if the underlying objects in native code are the same object. That means you can have two different Java objects, but when you do a comparison, you'll find out they are the EXACT same object.- Overrides:
equalsin classjava.lang.Object- Returns:
- True if the underlying native object is the same. False otherwise.
-
hashCode
public int hashCode()
Get a hashable value for this object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashable value.
-
finalize
protected void finalize()
Internal Only. Finalize this object. Note this should only exists on non RefCounted objects.- Overrides:
finalizein classjava.lang.Object
-
delete
public void delete()
Releases any underlying native memory and marks this object as invalid.Normally Ferry manages when to release native memory.
In the unlikely event you want to control EXACTLY when a native object is released, each AVPKit object has a
delete()method that you can use. Once you calldelete(), you must ENSURE your object is never referenced again from that Java object -- Ferry tries to help you avoid crashes if you accidentally use an object after deletion but on this but we cannot offer 100% protection (specifically if another thread is accessing that object EXACTLY when youdelete()it).
-
get
public int get()
-
set
public void set(int arg0)
-
getAndSet
public int getAndSet(int arg0)
-
getAndIncrement
public int getAndIncrement()
-
getAndDecrement
public int getAndDecrement()
-
getAndAdd
public int getAndAdd(int arg0)
-
incrementAndGet
public int incrementAndGet()
-
decrementAndGet
public int decrementAndGet()
-
addAndGet
public int addAndGet(int arg0)
-
compareAndSet
public boolean compareAndSet(int expected, int update)
Compare the current value to expected, and if
they are equal, set the current value to update.- Parameters:
expected- the value expectedupdate- the value to update to- Returns:
- true if equal
-
isAtomic
public boolean isAtomic()
- Returns:
- true if we're actually able to guarantee
atomicity; false if we can't.
-
-