Close Once
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.
Parameters
on Close
The function to invoke on the first call to close.