Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How is it possible then that core.async works on javascript platform, a platform that has no mutexes?

Maybe there is a lock to implement the thread macro (clojure only), but then that uses native threads. How would you propose to handle access to channels between native threads without locks?

As far as I know there is no locking performed in asynchronous code implemented using the go macro. The go macro is a macro that turns your code inside out into a state machine, is it not? Each <! and >! point becomes and entry/exit into that state machine. There are no locks here because the go macro can essentially "rewrite" your source code for you and there is only a single thread of execution through the interconnected state machines.



There are obviously platform-specific implementations. In Clojure, core.async utilizes locks, and the original comment wasn't referring to ClojureScript.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: