mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
return results, see pr #403
This commit is contained in:
@@ -8,6 +8,19 @@ function skynet.queue()
|
||||
local current_thread
|
||||
local ref = 0
|
||||
local thread_queue = {}
|
||||
|
||||
local function xpcall_ret(ok, ...)
|
||||
ref = ref - 1
|
||||
if ref == 0 then
|
||||
current_thread = table.remove(thread_queue,1)
|
||||
if current_thread then
|
||||
skynet.wakeup(current_thread)
|
||||
end
|
||||
end
|
||||
assert(ok, (...))
|
||||
return ...
|
||||
end
|
||||
|
||||
return function(f, ...)
|
||||
local thread = coroutine.running()
|
||||
if current_thread and current_thread ~= thread then
|
||||
@@ -18,15 +31,7 @@ function skynet.queue()
|
||||
current_thread = thread
|
||||
|
||||
ref = ref + 1
|
||||
local ok, err = xpcall(f, traceback, ...)
|
||||
ref = ref - 1
|
||||
if ref == 0 then
|
||||
current_thread = table.remove(thread_queue,1)
|
||||
if current_thread then
|
||||
skynet.wakeup(current_thread)
|
||||
end
|
||||
end
|
||||
assert(ok,err)
|
||||
return xpcall_ret(xpcall(f, traceback, ...))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user