lua.wetgenes.tasks.add_thread
local thread=tasks:add_thread({
id="test",
count=1,
code=function(linda,task_id,task_idx)
while true do
local _,memo= linda:receive( nil , task_id )
if memo then
...
end
end
end,
})
Create a thread with various preset values:
id
A unique id string to be used by lindas when sending messages into this task. The function is expected to sit in an infinite loop waiting on this linda socket.
count
The number of threads to create, they will all use the same instanced code function so should be interchangable and it should not matter which thread we are actually running code on. If you expect the task to maintain some state between memos, then this must be 1 .
code
A lua function to run inside each thread, this function will recieve tasks.linda and the task.id for comunication and an index so we know which of the count threads we are (mostly for debugging)