mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
recycle coroutine bugfix
This commit is contained in:
@@ -134,8 +134,6 @@ local function co_create(f)
|
|||||||
skynet.address(session_coroutine_address[co]),
|
skynet.address(session_coroutine_address[co]),
|
||||||
source.source, source.linedefined))
|
source.source, source.linedefined))
|
||||||
end
|
end
|
||||||
f = nil
|
|
||||||
coroutine_pool[#coroutine_pool+1] = co
|
|
||||||
-- coroutine exit
|
-- coroutine exit
|
||||||
local tag = session_coroutine_tracetag[co]
|
local tag = session_coroutine_tracetag[co]
|
||||||
if tag then
|
if tag then
|
||||||
@@ -148,12 +146,19 @@ local function co_create(f)
|
|||||||
session_coroutine_id[co] = nil
|
session_coroutine_id[co] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- recycle co into pool
|
||||||
|
f = nil
|
||||||
|
coroutine_pool[#coroutine_pool+1] = co
|
||||||
|
-- recv new main function f
|
||||||
f = coroutine_yield "SUSPEND"
|
f = coroutine_yield "SUSPEND"
|
||||||
f(coroutine_yield())
|
f(coroutine_yield())
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
|
-- pass the main function f to coroutine, and restore running thread
|
||||||
|
local running = running_thread
|
||||||
coroutine_resume(co, f)
|
coroutine_resume(co, f)
|
||||||
|
running_thread = running
|
||||||
end
|
end
|
||||||
return co
|
return co
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user