Skip to content

Commit

Permalink
Make Channel implement AutoCloseable
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Jan 22, 2024
1 parent 9c43ed0 commit 22699e7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/src/main/java/com/softwaremill/jox/CloseableChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* <p>
* Closing the channel is thread-safe.
*/
public interface CloseableChannel {
public interface CloseableChannel extends AutoCloseable {
/**
* Close the channel, indicating that no more elements will be sent.
* <p>
Expand All @@ -40,6 +40,15 @@ public interface CloseableChannel {
*/
Object doneSafe();

/**
* Same as {@link #done()}: close the channel, indicating that no more elements will be sent.
* <p>
* Enables using channel in {@code try-with-resources} blocks.
*/
default void close() {
done();
}

//

/**
Expand Down

0 comments on commit 22699e7

Please sign in to comment.