Skip to content

Commit

Permalink
Add specialization for :shutdown-on-failure on structured-task-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Oct 24, 2023
1 parent 6cc14a7 commit 658c429
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/promesa/exec.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,25 @@
(let [task (wrap-bindings task)]
(.fork ^java.util.concurrent.StructuredTaskScope it ^Callable task))))))

#?(:clj
(pu/with-compile-cond structured-task-scope-available?
(extend-type java.util.concurrent.StructuredTaskScope$ShutdownOnFailure
pt/IAwaitable
(-await!
([it]
(.join ^java.util.concurrent.StructuredTaskScope$ShutdownOnFailure it)
(.throwIfFailed ^java.util.concurrent.StructuredTaskScope$ShutdownOnFailure it))
([it duration]
(let [duration (if (instance? Duration duration)
duration
(Duration/ofMillis duration))
deadline (Instant/now)
deadline (.plus ^Instant deadline
^TemporalAmount duration)]
(.joinUntil ^java.util.concurrent.StructuredTaskScope$ShutdownOnFailure it ^Instant deadline)
(.throwIfFailed ^java.util.concurrent.StructuredTaskScope$ShutdownOnFailure it)))))))


;; #?(:clj
;; (defn managed-blocker
;; {:no-doc true}
Expand Down

0 comments on commit 658c429

Please sign in to comment.