Hey, I made a similar suggestion (minus the ThreadLocal) a few weeks ago, although for slightly different reasons. [1]
It should be noted that your async macro does in fact use the dispatcher just like a normal go would, the only difference is that it will start executing immediately in the current thread until the first "pause" instead of dispatching. After the "pause" the dispatcher will run it though which is not guaranteed to be the same thread. Therefore I'm not actually sure a ThreadLocal will work. Did you test that you get the actual correct result? Your benchmark is also not very useful, you are basically just measuring the frameworks overhead which is tiny to what it provides. In actual programs most of the time will not be spent in core.async internals, at least not from what I have observed so far. go blocks are actually pretty cheap. YMMV, /thomas [1] http://dev.clojure.org/jira/browse/ASYNC-131 On Thursday, July 30, 2015 at 8:52:45 AM UTC+2, Martin Raison wrote: > > go blocks tend to spread in Clojure programs just like async/await in > C#/Hack/Python, etc. The problem is that they aren't cheap. > > I was curious to know what you guys think of the following workaround: > http://blog.martinraison.com/clojure/2015/07/27/clojure-core-async-go-blocks-everywhere.html > (TL;DR: use "go" only in the few functions that do some actual work, in > all other places use an alternate version - called "async" in the article - > that doesn't use the dispatcher and doesn't create a chan. The only thing > "async" does is handling the state machine stuff, so that <!, alt!, etc > work as expected.) > > Does that seem reasonable or do you see a better way to do this? > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.