Written by
Aaron Bell
on
on
Parking vs. blocking makes no difference to me atm
When using asynchronously running processes, i.e. with go macros or futures, blocking or parking make no difference to me atm. Atm I see no reason not to simplify things, using <!! exclusively instead of <! sometimes in a go
block.
;; Control, can use multiple expressions in the go body
(def my-chan (chan))
(println 1)
(go (println 2) (println 3))
(println 4)
;; (def my-chan (chan))
(println 1)
(go (>! my-chan "Hi") (println 2))
(println 3)
;; (def my-chan (chan))
(println 1)
(go (>!! my-chan "Hi") (println 2))
(println 3)
Neither #2 and #3 never print 2
. What’s the difference?
;; (def my-chan (chan))
(println 1)
(go (>!! my-chan "Hi") (println 2))
(go (>!! my-chan "Hi") (println 2))
(go (println 2))
(println 3)
;; (def my-chan (chan))
(println 1)
(go (>! my-chan "Hi") (println 2))
(go (>! my-chan "Hi") (println 2))
(go (println 2))
(println 3)
Both these sections do the same thing. From my perspective, >! performs exactly like >!!. Why complicate the asynchronous headspace with “parking” and “blocking”, when both block each’s current process?