Package smile.util

Class AutoScope

java.lang.Object
smile.util.AutoScope
All Implemented Interfaces:
AutoCloseable

public class AutoScope extends Object implements AutoCloseable
AutoScope allows for predictable, deterministic resource deallocation. AutoScope can be closed explicitly or be best used with try-with-resources Statement. Closing an AutoScope will cause all the cleanup actions associated with that scope to be called.
  • Constructor Details

    • AutoScope

      public AutoScope(AutoCloseable... resources)
      Constructors.
      Parameters:
      resources - the resources to be attached to this scope.
  • Method Details

    • attach

      public AutoScope attach(AutoCloseable... resources)
      Attaches resources to this Scope.
      Parameters:
      resources - the resources to be attached to this scope.
      Returns:
      this object.
    • detach

      public AutoScope detach(AutoCloseable... resources)
      Detaches resources from this Scope.
      Parameters:
      resources - the resources to be detached from this scope.
      Returns:
      this object.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable