Package org.webrtc

Class RefCountDelegate

java.lang.Object
org.webrtc.RefCountDelegate
All Implemented Interfaces:
RefCounted

class RefCountDelegate extends Object implements RefCounted
Implementation of RefCounted that executes a Runnable once the ref count reaches zero.
  • Field Details

    • refCount

      private final AtomicInteger refCount
    • releaseCallback

      @Nullable private final Runnable releaseCallback
  • Constructor Details

    • RefCountDelegate

      public RefCountDelegate(@Nullable Runnable releaseCallback)
      Parameters:
      releaseCallback - Callback that will be executed once the ref count reaches zero.
  • Method Details

    • retain

      public void retain()
      Description copied from interface: RefCounted
      Increases ref count by one.
      Specified by:
      retain in interface RefCounted
    • release

      public void release()
      Description copied from interface: RefCounted
      Decreases ref count by one. When the ref count reaches zero, resources related to the object will be freed.
      Specified by:
      release in interface RefCounted
    • safeRetain

      boolean safeRetain()
      Tries to retain the object. Can be used in scenarios where it is unknown if the object has already been released. Returns true if successful or false if the object was already released.