4 ms·
Has someone implemented the same subset of CSP as in Go, but done it in Lua? Could it be done? Does concurrency in Lua depend on everyone calling yield when the
by stcredzero 14y ago
Has someone implemented the same subset of CSP as in Go, but done it in Lua? Could it be done? Does concurrency in Lua depend on everyone calling yield when they're supposed to?
- silentbicycle 14y agoConcurrency in Lua's core language is co-operative (coroutines explicitly yield to each other). This is because the language designers don't want to impose any particular threading architecture -- Lua is intentded to be as portable and non-opinionated about that sort of thing as possible. Its coroutines are intended for the same sort of issues as generators/callbacks/continuations, not for explicit parallelism. They won't do multi-core mapreduce, but they'll let you cleanly factor code that has multiple main loops. You can get multi-threaded/multi-process concurrency by messaging between separate Lua VMs, using libraries such as Lua Lanes (http://kotisivu.dnainternet.net/askok/bin/lanes/ http://kotisivu.dnainternet.net/askok/bin/lanes/). The Lua VM is implemented without static state, so several VMs can run in the same process without a GIL. There is LuaPi (https://github.com/LuaDist/luapi https://github.com/LuaDist/luapi), an implementation of the Pi calculus (a variant of CSP), but I don't really know much about it. I'm more familiar with Erlang-flavored concurrency models (and there's also ConcurrentLua, https://github.com/lefcha/concurrentlua https://github.com/lefcha/concurrentlua).
- catwell 14y agoIn addition to that you may want to look at https://github.com/loyso/LuaCSP https://github.com/loyso/LuaCSP - it is not implemented in Lua but it extends the language with CSP.
- stcredzero 14y agoI wonder why this guy says FSM are non-composable? I've done something that could be termed as "orthogonal" combination of multiple FSMs. It's also possible for one FSM to "freeze" the operation of another and "unfreeze" a 3rd. I know, because I've done it.
- asb 14y agoThere's some other choices which are interesting to me: luaproc as described in http://www.inf.puc-rio.br/~roberto/docs/ry08-05.pdf http://www.inf.puc-rio.br/~roberto/docs/ry08-05.pdf is nice and simple. I'm also interested in lua-zmq.threads for LuaJIT which uses zeromq for message passing between threads. http://lua-users.org/lists/lua-l/2011-04/msg00364.html http://lua-users.org/lists/lua-l/2011-04/msg00364.html and https://github.com/Neopallium/lua-zmq https://github.com/Neopallium/lua-zmq