@@ -30,12 +30,11 @@ to catch and handle."
3030 clojure.core.async.impl.go ; ; TODO: make conditional
3131 [clojure.core.async.impl.mutex :as mutex]
3232 [clojure.core.async.impl.concurrent :as conc]
33- [clojure.core.async.impl.exec.threadpool :as threadp] )
33+ )
3434 (:import [java.util.concurrent.atomic AtomicLong]
3535 [java.util.concurrent.locks Lock]
3636 [java.util.concurrent Executors Executor ThreadLocalRandom ExecutorService]
37- [java.util Arrays ArrayList]
38- [clojure.lang Var]))
37+ [java.util Arrays ArrayList]))
3938
4039(alias 'core 'clojure.core)
4140
@@ -462,24 +461,7 @@ to catch and handle."
462461 [& body]
463462 (#'clojure.core.async.impl.go/go-impl &env body))
464463
465- (defn- best-fit-thread-call
466- [f exec]
467- (let [c (chan 1 )
468- ^ExecutorService e (case exec
469- :compute threadp/compute-executor
470- :io threadp/io-executor
471- threadp/mixed-executor)]
472- (let [binds (Var/getThreadBindingFrame )]
473- (.execute e
474- (fn []
475- (Var/resetThreadBindingFrame binds)
476- (try
477- (let [ret (f )]
478- (when-not (nil? ret)
479- (>!! c ret)))
480- (finally
481- (close! c))))))
482- c))
464+ (require '[clojure.core.async.impl.exec.services :as exec-services])
483465
484466(defn thread-call
485467 " Executes f in another thread, returning immediately to the calling
@@ -488,15 +470,15 @@ to catch and handle."
488470 nature of f's workload, one of :mixed (default) :io or :compute
489471 whereby core.async may be able to choose a best fit thread type."
490472 [f]
491- (best-fit-thread-call f :mixed ))
473+ (exec-services/ best-fit-thread-call f :mixed ))
492474
493475(defmacro io-thread
494476 " Executes the body in a thread intended for blocking I/O workloads,
495477 returning immediately to the calling thread. The body must not do
496478 extended computation (if so, use 'thread' instead). Returns a channel
497479 which will receive the result of the body when completed, then close."
498480 [& body]
499- `(#' best-fit-thread-call (^:once fn* [] ~@body) :io ))
481+ `(exec-services/ best-fit-thread-call (^:once fn* [] ~@body) :io ))
500482
501483(defmacro thread
502484 " Executes the body in another thread, returning immediately to the
0 commit comments