lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Marc:
You may be interested in this similar project: https://github.com/cloudwu/skynet .

Regards
Long
于 2014/6/6 4:34, Marc Balmer 写道:
Lua nodes is a "different" way to execute Lua code. It combines three existing technologies: Lua, POSIX threads, and, 0MQ (zeromq.orq). Lua nodes comes as a binary, called "node", which takes a filename of a Lua program as argument. This Lua program is meant to "orchestrate" a network of Nodes.

This program can thus create "nodes" using the "node" module. Nodes are independent Lua states running in their own thread. Nodes can communicate using 0MQ (zeromq) message queues. The Lua states run truly in parallel and use all available CPU cores. This has nothing to do with Lua coroutines (which are still available to each Lua state).

Nodes can communicate between threads in the same process, processes on the same machine, or, processes on different machines by using zeromq message queues. Lua nodes allow for full distributed/parallel processing, using a simple language, Lua.

A new Node (i.e. a Lua state running in its own thread) is created using node.create():

local n = node.create('worker.lua', 'bee', 42)

This will create a new thread with a new Lua state, running the chunk found in the file "worker.lua", passing the arguments "bee" and 42 in "..." to worker.lua.

Nodes can use the "zmq" module to communicate with each other. So it is possible to run multiple independend Lua threads in one process and have them communicate with each other, or with Nodes in differents processes on the same machine, or with Nodes running on a remote machines.

Comments, suggestions, and, ideas welcome.