Class 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 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.
    • 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:
        equals in class java.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:
        hashCode in class java.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:
        finalize in class java.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 call delete(), 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 you delete() it).

      • get

        public int get()
      • set

        public void set​(int arg0)
      • getAndSet

        public int getAndSet​(int arg0)
      • getAndAdd

        public int getAndAdd​(int arg0)
      • 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 expected
        update - 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.