如何批量调用含有阻塞操作的函数, 并等待全部返回才继续执行下面的逻辑 #1602
zhangshiqian1214
started this conversation in
General
Replies: 3 comments 9 replies
-
看一下 test/testselect.lua 是否能满足你需求 |
Beta Was this translation helpful? Give feedback.
7 replies
-
调用一个本地的函数可以转换为 skynet.call , 我随手写了一段代码,没测试: skynet.dispatch("invoke", function(session, address, id)
local f = task[id]
task[id] = nil
skynet.ret(skynet.pack(f())
end)
local task = {}
local function invoke(func)
local n = #task+1
task[n] = func
return skynet.self(), "invoke", n
end
--skynet.call(invoke(function()
--- do something
-- end)) |
Beta Was this translation helpful? Give feedback.
2 replies
-
感谢,飘雪已经收到已经了。Thanks, snow has been received already
|
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
-
#1175
在某种情况下, 比如批量调含有http操作的函数里面, 因为不是直接调用skynet.call, 所以skynet.select不适用这种情况, 对parallels进行测试, 发现有时会出现还没有等所有操作完成, 就唤醒了wait
Beta Was this translation helpful? Give feedback.
All reactions