File tree Expand file tree Collapse file tree
main/clojure/clojure/core/async/flow
test/clojure/clojure/core/async Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 [clojure.core.async.impl.dispatch :as disp]
1515 [clojure.walk :as walk]
1616 [clojure.datafy :as datafy])
17- (:import [java.util.concurrent Future Executors Executor TimeUnit]
17+ (:import [java.util.concurrent Future Executor TimeUnit CompletableFuture ]
1818 [java.util.concurrent.locks ReentrantLock]))
1919
2020(set! *warn-on-reflection* true )
3030 (fn [& args]
3131 (let [^Executor e (if (instance? Executor exec)
3232 exec
33- (disp/executor-for exec))]
34- (.execute e ^Runnable #(apply f args)))))
33+ (disp/executor-for exec))
34+ fut (CompletableFuture. )]
35+ (.execute e #(.complete fut (apply f args)))
36+ fut)))
3537
3638(defn prep-proc [ret pid {:keys [proc, args, chan-opts] :or {chan-opts {}}}]
3739 (let [{:keys [ins outs signal-select]} (spi/describe proc)
Original file line number Diff line number Diff line change 1+ ; ; Copyright (c) Rich Hickey and contributors. All rights reserved.
2+ ; ; The use and distribution terms for this software are covered by the
3+ ; ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4+ ; ; which can be found in the file epl-v10.html at the root of this distribution.
5+ ; ; By using this software in any fashion, you are agreeing to be bound by
6+ ; ; the terms of this license.
7+ ; ; You must not remove this notice, or any other, from this software.
8+
9+ (ns clojure.core.async.flow-test
10+ (:require [clojure.test :refer :all ]
11+ [clojure.core.async.flow :as flow]))
12+
13+ (deftest test-futurize
14+ (testing " "
15+ (let [in-es? (atom false )
16+ es (reify java.util.concurrent.Executor
17+ (^void execute [_ ^Runnable f]
18+ (reset! in-es? true )
19+ (future-call f)))]
20+ (is (= 16 @((flow/futurize #(* % %) {:exec :mixed }) 4 )))
21+ (is (= 16 @((flow/futurize #(* % %)) 4 )))
22+ (is (= 16 @((flow/futurize #(* % %) {:exec es}) 4 )))
23+ (is @in-es?))))
24+
You can’t perform that action at this time.
0 commit comments