Skip to content

Commit

Permalink
Merge pull request #658 from gemini-hlsw/avoid-double-closure
Browse files Browse the repository at this point in the history
Avoid double closure of drained effect stream resources
  • Loading branch information
rpiaggio authored Oct 7, 2024
2 parents eb4f271 + 087903b commit 42da35b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ object UseEffectStreamResource {
(stream.compile.drain >> latch.complete(())).background.void
.allocated
supervisor <- (latch.get >> close).start // Close the resource if the stream terminates.
yield supervisor.cancel >> close // Cleanup closes resource and cancels the supervisor.
yield
// Cleanup closes resource and cancels the supervisor, unless resource is already closed.
(supervisor.cancel >> close).when:
latch.tryGet.map(_.isEmpty)
.build

object HooksApiExt {
Expand Down

0 comments on commit 42da35b

Please sign in to comment.