Package smile.util
Class AutoScope
java.lang.Object
smile.util.AutoScope
- All Implemented Interfaces:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionattach
(AutoCloseable... resources) Attaches resources to this Scope.void
close()
detach
(AutoCloseable... resources) Detaches resources from this Scope.
-
Constructor Details
-
AutoScope
Constructors.- Parameters:
resources
- the resources to be attached to this scope.
-
-
Method Details
-
attach
Attaches resources to this Scope.- Parameters:
resources
- the resources to be attached to this scope.- Returns:
- this object.
-
detach
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 interfaceAutoCloseable
-