|
10 | 10 | [manifold.stream :as s])
|
11 | 11 | (:import (manifold.stream.core IEventSource)))
|
12 | 12 |
|
| 13 | +;; a number of functions from `ioc-macros` moved to `runtime` in org.clojure/core.async "1.6.673" |
| 14 | +;; since they were just moved without functionality changes, continue to support both via dynamic import |
| 15 | +(if (find-ns 'clojure.core.async.impl.runtime) |
| 16 | + (require '[clojure.core.async.impl.runtime :as async-runtime]) |
| 17 | + (require '[clojure.core.async.impl.ioc-macros :as async-runtime])) |
| 18 | + |
13 | 19 | (defn ^:no-doc return-deferred [state value]
|
14 |
| - (let [d (ioc/aget-object state ioc/USER-START-IDX)] |
| 20 | + (let [d (async-runtime/aget-object state async-runtime/USER-START-IDX)] |
15 | 21 | (d/success! d value)
|
16 | 22 | d))
|
17 | 23 |
|
|
38 | 44 | r#)))
|
39 | 45 |
|
40 | 46 | (defn ^:no-doc run-state-machine-wrapped [state]
|
41 |
| - (try (ioc/run-state-machine state) |
| 47 | + (try (async-runtime/run-state-machine state) |
42 | 48 | (catch Throwable ex
|
43 |
| - (d/error! (ioc/aget-object state ioc/USER-START-IDX) ex) |
| 49 | + (d/error! (async-runtime/aget-object state async-runtime/USER-START-IDX) ex) |
44 | 50 | (throw ex))))
|
45 | 51 |
|
46 | 52 | (defn ^:no-doc take! [state blk d]
|
47 | 53 | (let [handler (fn [x]
|
48 |
| - (ioc/aset-all! state ioc/VALUE-IDX x ioc/STATE-IDX blk) |
| 54 | + (async-runtime/aset-all! state async-runtime/VALUE-IDX x async-runtime/STATE-IDX blk) |
49 | 55 | (run-state-machine-wrapped state))
|
50 | 56 | ;; if `d` is a stream, use `take` to get a deferrable that we can wait on
|
51 | 57 | d (if (instance? IEventSource d) (s/take! d) d)
|
52 | 58 | d-is-deferrable? (d/deferrable? d)]
|
53 | 59 | (if
|
54 | 60 | ;; if d is not deferrable immediately resume processing state machine
|
55 | 61 | (not d-is-deferrable?)
|
56 |
| - (do (ioc/aset-all! state ioc/VALUE-IDX d ioc/STATE-IDX blk) |
| 62 | + (do (async-runtime/aset-all! state async-runtime/VALUE-IDX d async-runtime/STATE-IDX blk) |
57 | 63 | :recur)
|
58 | 64 | (let [d (d/->deferred d)]
|
59 | 65 | (if
|
60 | 66 | ;; if already realized, deref value and immediately resume processing state machine
|
61 | 67 | (d/realized? d)
|
62 |
| - (do (ioc/aset-all! state ioc/VALUE-IDX @d ioc/STATE-IDX blk) |
| 68 | + (do (async-runtime/aset-all! state async-runtime/VALUE-IDX @d async-runtime/STATE-IDX blk) |
63 | 69 | :recur)
|
64 | 70 |
|
65 | 71 | ;; resume processing state machine once d has been realized
|
|
84 | 90 | (let [~@(mapcat (fn [[l sym]] [sym `(^:once fn* [] ~(vary-meta l dissoc :tag))]) crossing-env)
|
85 | 91 | f# ~(ioc/state-machine `(do ~@body) 1 [crossing-env &env] async-custom-terminators)
|
86 | 92 | state# (-> (f#)
|
87 |
| - (ioc/aset-all! ioc/USER-START-IDX d# |
88 |
| - ioc/BINDINGS-IDX captured-bindings#))] |
| 93 | + (async-runtime/aset-all! async-runtime/USER-START-IDX d# |
| 94 | + async-runtime/BINDINGS-IDX captured-bindings#))] |
89 | 95 | (run-state-machine-wrapped state#))))
|
90 | 96 | ;; chain is8 being used to apply unwrap chain
|
91 | 97 | (d/chain d#)))
|
|
0 commit comments