Replies: 1 comment
-
select 是解决这个问题加的特性。 https://github.com/cloudwu/skynet/blob/master/lualib/skynet.lua#L185-L199 看代码实现是按 add 的顺序执行 send 的,不用等返回直接 send 下一个的,但是遍历结果是谁先返回谁先进循环,你可以在 console 里运行 start testselect 试试的。 所以投递消息是按顺序投递到不同服务的,哪个服务先收到是不确定的,但是投递到同一个服务是按顺序投递的就会是按顺序接收的。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
local reqs = skynet.request()
for i = 1, 10 do
reqs:add { slave, "lua", "ping", i*10, "SLEEP " .. i, token = i }
end
for req, resp in reqs:select() do
info("RESP %s token<%s>", resp[1], req.token)
end
看到skynet.request的例子,我想问问,如果添加多个请求同时是针对不同的服务目标的,请问在执行的时候,是并发投递多个服务目标吗?还是会一个个的按添加顺序请求。
Beta Was this translation helpful? Give feedback.
All reactions