Class Mutex


  • public class Mutex
    extends RefCounted
    Internal Only.


    This object exists so that Native code can get access to
    thread safe locking objects if they need it.


    Implements a blocking Mutually-Exclusive lock
    by wrapping a Java lock.


    If not running inside Java, lock() and unlock()
    are NO-OPs.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Mutex​(long cPtr, boolean cMemoryOwn)
      Internal Only.
      protected Mutex​(long cPtr, boolean cMemoryOwn, java.util.concurrent.atomic.AtomicLong ref)
      Internal Only.
    • Constructor Detail

      • Mutex

        protected Mutex​(long cPtr,
                        boolean cMemoryOwn)
        Internal Only.
      • Mutex

        protected Mutex​(long cPtr,
                        boolean cMemoryOwn,
                        java.util.concurrent.atomic.AtomicLong ref)
        Internal Only.
    • Method Detail

      • getCPtr

        public static long getCPtr​(Mutex 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.
        Overrides:
        getMyCPtr in class RefCounted
        Returns:
        The raw pointer we're proxying for.
      • copyReference

        public Mutex copyReference()
        Create a new Mutex object that is actually referring to the exact same underlying native object.
        Overrides:
        copyReference in class RefCounted
        Returns:
        the new Java object.
      • 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.
      • lock

        public void lock()
      • unlock

        public void unlock()