recycle coroutine bugfix

This commit is contained in:
Cloud Wu
2018-06-07 17:27:21 +08:00
committed by 云风
parent b1ec1f4d18
commit 4b5fbab129

View File

@@ -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