Class CleanerDrop<T extends Buffer>

  • All Implemented Interfaces:
    Drop<T>

    public final class CleanerDrop<T extends Buffer>
    extends Object
    implements Drop<T>
    A drop implementation that delegates to another drop instance, either when called directly, or when it becomes cleanable. This ensures that objects are dropped even if they leak.
    • Method Detail

      • wrap

        public static <T extends BufferDrop<T> wrap​(Drop<T> drop,
                                                      MemoryManager manager)
        Wrap the given drop instance, and produce a new drop instance that will also call the delegate drop instance if it becomes cleanable.
      • attach

        public void attach​(T obj)
        Description copied from interface: Drop
        Called when the resource changes owner.
        Specified by:
        attach in interface Drop<T extends Buffer>
        Parameters:
        obj - The new Resource instance with the new owner.
      • drop

        public void drop​(T obj)
        Description copied from interface: Drop
        Dispose of the resources in the given Resource instance.
        Specified by:
        drop in interface Drop<T extends Buffer>
        Parameters:
        obj - The Resource instance being dropped.
      • fork

        public Drop<T> fork()
        Description copied from interface: Drop
        Branch the responsibility of dropping a resource. This drop instance will remain associated with its current resource, while the returned drop instance must be attached to its new resource.
        Specified by:
        fork in interface Drop<T extends Buffer>
        Returns:
        A drop instance, similar to this one, but for the purpose of being associated with a different but related resource.