|
6 | 6 | [executor :as ex]
|
7 | 7 | [deferred :as d]]
|
8 | 8 | [clojure.core.async.impl
|
| 9 | + [runtime :as async-runtime] |
9 | 10 | [ioc-macros :as ioc]]
|
10 | 11 | [manifold.stream :as s])
|
11 | 12 | (:import (manifold.stream.core IEventSource)))
|
12 | 13 |
|
13 | 14 | (defn ^:no-doc return-deferred [state value]
|
14 |
| - (let [d (ioc/aget-object state ioc/USER-START-IDX)] |
| 15 | + (let [d (async-runtime/aget-object state async-runtime/USER-START-IDX)] |
15 | 16 | (d/success! d value)
|
16 | 17 | d))
|
17 | 18 |
|
|
38 | 39 | r#)))
|
39 | 40 |
|
40 | 41 | (defn ^:no-doc run-state-machine-wrapped [state]
|
41 |
| - (try (ioc/run-state-machine state) |
| 42 | + (try (async-runtime/run-state-machine state) |
42 | 43 | (catch Throwable ex
|
43 |
| - (d/error! (ioc/aget-object state ioc/USER-START-IDX) ex) |
| 44 | + (d/error! (async-runtime/aget-object state async-runtime/USER-START-IDX) ex) |
44 | 45 | (throw ex))))
|
45 | 46 |
|
46 | 47 | (defn ^:no-doc take! [state blk d]
|
47 | 48 | (let [handler (fn [x]
|
48 |
| - (ioc/aset-all! state ioc/VALUE-IDX x ioc/STATE-IDX blk) |
| 49 | + (async-runtime/aset-all! state async-runtime/VALUE-IDX x async-runtime/STATE-IDX blk) |
49 | 50 | (run-state-machine-wrapped state))
|
50 | 51 | ;; if `d` is a stream, use `take` to get a deferrable that we can wait on
|
51 | 52 | d (if (instance? IEventSource d) (s/take! d) d)
|
52 | 53 | d-is-deferrable? (d/deferrable? d)]
|
53 | 54 | (if
|
54 | 55 | ;; if d is not deferrable immediately resume processing state machine
|
55 | 56 | (not d-is-deferrable?)
|
56 |
| - (do (ioc/aset-all! state ioc/VALUE-IDX d ioc/STATE-IDX blk) |
| 57 | + (do (async-runtime/aset-all! state async-runtime/VALUE-IDX d async-runtime/STATE-IDX blk) |
57 | 58 | :recur)
|
58 | 59 | (let [d (d/->deferred d)]
|
59 | 60 | (if
|
60 | 61 | ;; if already realized, deref value and immediately resume processing state machine
|
61 | 62 | (d/realized? d)
|
62 |
| - (do (ioc/aset-all! state ioc/VALUE-IDX @d ioc/STATE-IDX blk) |
| 63 | + (do (async-runtime/aset-all! state async-runtime/VALUE-IDX @d async-runtime/STATE-IDX blk) |
63 | 64 | :recur)
|
64 | 65 |
|
65 | 66 | ;; resume processing state machine once d has been realized
|
|
84 | 85 | (let [~@(mapcat (fn [[l sym]] [sym `(^:once fn* [] ~(vary-meta l dissoc :tag))]) crossing-env)
|
85 | 86 | f# ~(ioc/state-machine `(do ~@body) 1 [crossing-env &env] async-custom-terminators)
|
86 | 87 | state# (-> (f#)
|
87 |
| - (ioc/aset-all! ioc/USER-START-IDX d# |
88 |
| - ioc/BINDINGS-IDX captured-bindings#))] |
| 88 | + (async-runtime/aset-all! async-runtime/USER-START-IDX d# |
| 89 | + async-runtime/BINDINGS-IDX captured-bindings#))] |
89 | 90 | (run-state-machine-wrapped state#))))
|
90 | 91 | ;; chain is8 being used to apply unwrap chain
|
91 | 92 | (d/chain d#)))
|
|
0 commit comments