Skip to content

Commit

Permalink
Add default-on-timeout arity to await and await! helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Jan 16, 2024
1 parent 60d3f16 commit 0c5ed6a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Changelog #


## Version 12.0.xxx

- Add integration with StructuredTaskScope (Structured Concurrency)
- Remove deprecated executors constructors (deprecated in v9)
- Add default-on-timeout arity for `p/await` and `p/await!`.
- Add helper for properly unwrap concurrent exceptions: `pu/unwrap-exception`

BREAKING CHANGES:

Expand Down
8 changes: 6 additions & 2 deletions src/promesa/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,12 @@
([resource]
(pt/-await! resource))
([resource duration]
(await! resource duration nil))
([resource duration default-on-timeout]
(try
(pt/-await! resource duration)
(catch TimeoutException _
nil)))))
default-on-timeout)))))

#?(:clj
(defn await
Expand All @@ -798,10 +800,12 @@
(catch Throwable cause
cause)))
([resource duration]
(await resource duration nil))
([resource duration default-on-timeout]
(try
(pt/-await! resource duration)
(catch TimeoutException _
nil)
default-on-timeout)
(catch InterruptedException cause
(throw cause))
(catch Throwable cause
Expand Down
2 changes: 1 addition & 1 deletion src/promesa/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
(-closed? [it]
(.isShutdown it))
(-close! [it]
(.close it))
(.close ^java.lang.AutoCloseable it))

java.lang.AutoCloseable
(-closed? [_]
Expand Down

0 comments on commit 0c5ed6a

Please sign in to comment.