|
|
|
|
|
by pron
4516 days ago
|
|
If you're using callbacks at all, then you're not blocking. The main advantage threads (and lightweight threads) have is that they can block. What you can't do is this: (defn foo [ch]
(go
(bar ch)))
(defn bar [ch]
(<! ch))
foo starts a go block which calls bar, which then blocks on the channel. For threads that's ok: (defn foo [ch]
(thread ; not sure about syntax here
(bar ch)))
(defn bar [ch]
(<!! ch))
So a function running in a thread can call another function that blocks. A go block can't, that's why go blocks aren't lightweight threads.BTW, in Pulsar's implementation of core.async, the first example is ok, too. |
|