Package 

Class CloseOnce

  • All Implemented Interfaces:
    app.rive.core.CheckableAutoCloseable , java.lang.AutoCloseable

    
    public final class CloseOnce
     implements CheckableAutoCloseable
                        

    Utility to make CheckableAutoCloseable idempotent.

    If everything required for disposal is available from the constructor, you can implement via delegation: class Foo(...) : CheckableAutoCloseable by CloseOnce({ ... }). Otherwise, use as a member variable, e.g.: private val closer = CloseOnce { ... }, and forward close and closed to it.

    Thread-safe, performing a no-op after the first close.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Boolean closed
    • Constructor Summary

      Constructors 
      Constructor Description
      CloseOnce(String label, Function0<Unit> onClose)
    • Method Summary

      Modifier and Type Method Description
      Boolean getClosed()
      Unit close() Closes this resource, releasing any underlying resources.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CloseOnce

        CloseOnce(String label, Function0<Unit> onClose)
        Parameters:
        onClose - The function to invoke on the first call to close.