Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function x(c)
- for i=1, 10 do
- c:IN(i)
- end
- end
- function y(c)
- for i=1, 10 do
- -- this blocks until something is received on the channel...
- -- might instead need to be:
- -- x=c:OUT()
- -- print(x)
- print(c:OUT())
- end
- end
- ch = Channel:new()
- swm = Swarm:new()
- -- c is passed to each function in the swarm.
- -- An alternative would be something like:
- -- s = Swarm:new(c)
- -- To denote that each function in the swarm is going to be called with a parameter
- -- or it could be done like in the examples the channel is shared via closure
- swm:go(x, y, c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement