Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions src/coroutine/make.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
local select = select
local create = coroutine.create
local isyieldable = coroutine.isyieldable -- luacheck: ignore
local resume = coroutine.resume
local running = coroutine.running
local status = coroutine.status
local wrap = coroutine.wrap
local yield = coroutine.yield
local select = select
local setmetatable = setmetatable
local create = coroutine.create
local isyieldable = coroutine.isyieldable -- luacheck: ignore
local resume = coroutine.resume
local running = coroutine.running
local status = coroutine.status
local wrap = coroutine.wrap
local yield = coroutine.yield

local _tagged = setmetatable({}, {__mode = 'kv'})

local _str_tags = setmetatable({}, {__mode = 'v'})

return function (tag)
if type(tag) == 'string' then
local _tag = _str_tags[tag] or {}
_str_tags[tag] = _tag
tag = _tag
end

tag = tag or {}

if _tagged[tag] then
return _tagged[tag]
end

local coroutine = {
isyieldable = isyieldable,
running = running,
status = status,
}
tag = tag or {}

_tagged[tag] = coroutine
local function for_wrap (co, ...)
if tag == ... then
return select (2, ...)
Expand Down