News for hackers. Stuff that matters.
Re:Implementing, Abstracting and Benchmarking Lightweight Th... by pron on Thursday February 06, 2014 @02:58PM (#7192578)
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.

There are no comments on this comment yet.