[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Erlang Style Cocurrency in Lua
- From: "Timothy Baldridge" <tbaldridge@...>
- Date: Tue, 13 Jan 2009 16:17:22 -0600
I spent some time last year learning Erlang, and I have to say, I love
the way it works. However, I find the syntax totally unusable for my
everyday use.
I have an idea for Lua after digging through its sources. I love Lua,
it's fast, simple and brain-dead easy to extend.What I would like to
do is add Erlang style co-currency and actor based programming models
to Lua. Basically the idea would be to spawn a separate LuaState for
each "process" (in the Erlang sense of the word). Then in the main
loop of the interpreter, we could exit early after a certain number of
OPS have been executed.
>From here we can spawn n+1 OS threads where n is the number of CPUs.
By cycling through the LuaStates we should be able to keep all the
CPUs busy all the time.
My idea is to add these extra LuaStates as "children" of the first
state created. In this way all the existing C modules should/might
continue to work. Granted if two processes call the same thread we may
have issues, but hey, it's not a perfect world.
Throw into this mix a simple ! operator so we can do:
pid ! message
And we would be on the road to having Erlang style co currency in Lua.
Is anyone interested in working on this with me? I know C like the
back of my hand, I could just use some feedback/backup in the codin
--
"One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs."
(Robert Firth)