Class CleanupPool

java.lang.Object
edu.wpi.first.util.cleanup.CleanupPool
All Implemented Interfaces:
AutoCloseable

public class CleanupPool
extends Object
implements AutoCloseable
An object containing a Stack of AutoCloseable objects that are closed when this object is closed.
  • Constructor Details

  • Method Details

    • register

      public <T extends AutoCloseable> T register​(T object)
      Registers an object in the object stack for cleanup.
      Type Parameters:
      T - The object type
      Parameters:
      object - The object to register
      Returns:
      The registered object
    • remove

      public void remove​(AutoCloseable object)
      Removes an object from the cleanup stack.
      Parameters:
      object - the object to remove
    • close

      public void close()
      Closes all objects in the stack.
      Specified by:
      close in interface AutoCloseable