Skip to content

Commit

Permalink
Improved Scope Javadoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowwoc committed Dec 30, 2024
1 parent 31b2bf3 commit 9388259
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions core/src/main/java/com/github/cowwoc/pouch/core/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
/**
* The lifespan of one or more variables.
* <p>
* Child scopes must call {@link #addChild(Scope)} at the end of their constructor and
* {@link #removeChild(Scope)} at the end of their {@link #close()} method.
* Child scopes must call {@link #addChild(Scope) parent.addChild(this)} at the end of their constructor and
* {@link #removeChild(Scope) parent.removeChild(this)} at the end of their {@link #close()} method.
* <p>
* Example implementation of the {@code close()} method:
* <p>
* <pre>
* {@code
* public void close()
* {
* if (!closed.compareAndSet(false, true))
* return;
* parent.removeChild(this);
* children.shutdown(CLOSE_TIMEOUT);
* }
* }</pre>
*/
public interface Scope extends AutoCloseable
{
Expand Down

0 comments on commit 9388259

Please sign in to comment.