We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f0eef11 commit de15886Copy full SHA for de15886
src/clj/clojure/core.clj
@@ -3704,6 +3704,19 @@
3704
"Returns true if coll implements Reversible"
3705
[coll] (instance? clojure.lang.Reversible coll))
3706
3707
+(defn pcalls
3708
+ "Executes the no-arg fns in parallel, returning a lazy sequence of
3709
+ their values"
3710
+ [& fns]
3711
+ (let [futs (.invokeAll clojure.lang.Agent/pooledExecutor fns)]
3712
+ (map #(.get %) futs)))
3713
+
3714
+(defmacro pvalues
3715
+ "Returns a lazy sequence of the values of the exprs, which are
3716
+ evaluated in parallel"
3717
+ [& exprs]
3718
+ `(pcalls ~@(map #(list `fn [] %) exprs)))
3719
3720
(defn pmap
3721
"Like map, except f is applied in parallel. Semi-lazy in that the
3722
parallel computation stays ahead of the consumption, but doesn't
0 commit comments