Skip to content

Commit

Permalink
Reformat promesa.core ns
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Dec 5, 2023
1 parent 2314a97 commit f120f1d
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions src/promesa/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@
([f executor]
(c/let [d (impl/deferred)]
(exec/run executor (fn []
(try
(f #(pt/-resolve! d %)
#(pt/-reject! d %))
(catch #?(:clj Exception :cljs :default) e
(pt/-reject! d e)))))
(try
(f #(pt/-resolve! d %)
#(pt/-reject! d %))
(catch #?(:clj Exception :cljs :default) e
(pt/-reject! d e)))))
d)))

(defn promise?
Expand Down Expand Up @@ -505,11 +505,11 @@
[callable]
(fn [& args]
(create (fn [resolve reject]
(c/let [args (c/-> (vec args) (conj resolve))]
(try
(apply callable args)
(catch #?(:clj Throwable :cljs js/Error) e
(reject e))))))))
(c/let [args (c/-> (vec args) (conj resolve))]
(try
(apply callable args)
(catch #?(:clj Throwable :cljs js/Error) e
(reject e))))))))

#?(:cljs
(defn ^{:jsdoc ["@constructor"]}
Expand Down Expand Up @@ -667,17 +667,17 @@
(if (recur? ~res-s)
(do
(promesa.exec/run
:vthread
~(if (seq names)
`(fn [] (apply ~tsym (:bindings ~res-s)))
tsym))
nil)
:vthread
~(if (seq names)
`(fn [] (apply ~tsym (:bindings ~res-s)))
tsym))
nil)
(~rsv-s ~res-s)))))))]
(promesa.exec/run
:vthread
~(if (seq names)
`(fn [] (~tsym ~@fvals))
tsym)))))))
:vthread
~(if (seq names)
`(fn [] (~tsym ~@fvals))
tsym)))))))

(defmacro recur
[& args]
Expand Down Expand Up @@ -767,42 +767,42 @@
~xs))

#?(:clj
(defn await!
"Generic await operation. Block current thread until some operation
(defn await!
"Generic await operation. Block current thread until some operation
terminates. Returns `nil` on timeout; does not catch any other
exception.
Default implementation for Thread, CompletableFuture and
CountDownLatch.
The return value is implementation specific."
([resource]
(pt/-await! resource))
([resource duration]
(try
(pt/-await! resource duration)
(catch TimeoutException _
nil)))))
([resource]
(pt/-await! resource))
([resource duration]
(try
(pt/-await! resource duration)
(catch TimeoutException _
nil)))))

#?(:clj
(defn await
"A exception safer variant of `await!`. Returns `nil` on timeout
(defn await
"A exception safer variant of `await!`. Returns `nil` on timeout
exception, forwards interrupted exception and all other exceptions
are returned as value, so user is responsible for checking if the returned
value is exception or not."
([resource]
(try
(pt/-await! resource)
(catch InterruptedException cause
(throw cause))
(catch Throwable cause
cause)))
([resource duration]
(try
(pt/-await! resource duration)
(catch TimeoutException _
nil)
(catch InterruptedException cause
(throw cause))
(catch Throwable cause
cause)))))
([resource]
(try
(pt/-await! resource)
(catch InterruptedException cause
(throw cause))
(catch Throwable cause
cause)))
([resource duration]
(try
(pt/-await! resource duration)
(catch TimeoutException _
nil)
(catch InterruptedException cause
(throw cause))
(catch Throwable cause
cause)))))

0 comments on commit f120f1d

Please sign in to comment.