Add process:flush, fix printing

This commit is contained in:
Scott Richmond 2022-06-02 19:10:41 -04:00
parent 8752ee0da1
commit 0aa7efcbb1
2 changed files with 14 additions and 4 deletions

View File

@ -66,12 +66,20 @@
:list {::data/type ::data/clj :list {::data/type ::data/clj
:name "list" :name "list"
:body (fn [] (keys @processes))} :body (fn [] (into [] (keys @processes)))}
:info {::data/type ::data/clj :info {::data/type ::data/clj
:name "info" :name "info"
:body (fn [pid] :body (fn [pid]
(let [process @(get @processes pid) (let [process @(get @processes pid)
queue (into [] (:queue process))] queue (into [] (:queue process))]
(assoc process :queue queue)))} (assoc process :queue queue ::data/dict true)))}
:flush {::data/type ::data/clj
:name "flush"
:body (fn [pid]
(let [process (get @processes pid)
queue (into [] (:queue @process))]
(swap! process #(assoc % :queue clojure.lang.PersistentQueue/EMPTY))
queue))}
}}) }})

View File

@ -31,7 +31,7 @@
(str "#{" (apply str (into [] show-keyed (dissoc v ::data/dict))) "}") (str "#{" (apply str (into [] show-keyed (dissoc v ::data/dict))) "}")
:else :else
(pr-str v))) (with-out-str (pp/pprint v))))
(defn- show-set [v] (defn- show-set [v]
(str "${" (apply str (into [] show-linear v)) "}")) (str "${" (apply str (into [] show-linear v)) "}"))
@ -47,7 +47,9 @@
(vector? v) (show-vector v) (vector? v) (show-vector v)
(set? v) (show-set v) (set? v) (show-set v)
(map? v) (show-map v) (map? v) (show-map v)
:else (with-out-str (pp/pprint v)))) :else
(with-out-str (pp/pprint v))
))
([v & vs] (apply str (into [] (comp (map show) (interpose " ")) (concat [v] vs)))) ([v & vs] (apply str (into [] (comp (map show) (interpose " ")) (concat [v] vs))))
) )