works
This commit is contained in:
parent
d401d03c55
commit
6be0b5bddf
1 changed files with 9 additions and 4 deletions
|
|
@ -28,8 +28,9 @@
|
||||||
|
|
||||||
(alter-var-root #'dispatch/executor-for (constantly executor-for))
|
(alter-var-root #'dispatch/executor-for (constantly executor-for))
|
||||||
|
|
||||||
(defn exec
|
#_#_(defn exec
|
||||||
[^Runnable r workload]
|
[^Runnable r workload]
|
||||||
|
(prn :r r :w workload)
|
||||||
(let [^ExecutorService e (executor-for workload)]
|
(let [^ExecutorService e (executor-for workload)]
|
||||||
(.execute e r)))
|
(.execute e r)))
|
||||||
|
|
||||||
|
|
@ -53,12 +54,16 @@
|
||||||
([f] (thread-call f :mixed))
|
([f] (thread-call f :mixed))
|
||||||
([f workload]
|
([f workload]
|
||||||
(let [c (async/chan 1)
|
(let [c (async/chan 1)
|
||||||
|
binds (vars/get-thread-binding-frame)
|
||||||
returning-to-chan (fn [bf]
|
returning-to-chan (fn [bf]
|
||||||
#(try
|
#(try
|
||||||
(when-some [ret (bf)]
|
(when-some [ret (bf)]
|
||||||
(async/>!! c ret))
|
(async/>!! c ret))
|
||||||
(finally (async/close! c))))]
|
(finally (async/close! c))))
|
||||||
(-> f bound-fn* returning-to-chan (exec workload))
|
f (fn []
|
||||||
|
(vars/reset-thread-binding-frame binds)
|
||||||
|
(f))]
|
||||||
|
(-> f #_bound-fn* returning-to-chan (dispatch/exec workload))
|
||||||
c)))
|
c)))
|
||||||
|
|
||||||
(defn -vthread-call
|
(defn -vthread-call
|
||||||
|
|
@ -81,7 +86,7 @@
|
||||||
|
|
||||||
(defn thread
|
(defn thread
|
||||||
[_ _ & body]
|
[_ _ & body]
|
||||||
`(~'clojure.core.async/thread-call (fn [] ~@body)))
|
`(~'clojure.core.async/thread-call (fn [] ~@body) :mixed))
|
||||||
|
|
||||||
(defn -vthread
|
(defn -vthread
|
||||||
[_ _ & body]
|
[_ _ & body]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue