From e5a094cfc9ecaaea9873905b37658b9227c8fe99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 24 Sep 2021 17:20:52 +0800 Subject: supports `$/cancelRequest` --- script/await.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'script/await.lua') diff --git a/script/await.lua b/script/await.lua index 2d27ae2c..495f381c 100644 --- a/script/await.lua +++ b/script/await.lua @@ -1,11 +1,12 @@ local timer = require 'timer' -local util = require 'utility' + +local wkmt = { __mode = 'k' } ---@class await local m = {} m.type = 'await' -m.coMap = setmetatable({}, { __mode = 'k' }) +m.coMap = setmetatable({}, wkmt) m.idMap = {} m.delayQueue = {} m.delayQueueIndex = 1 @@ -74,7 +75,7 @@ function m.setID(id, co) return end if not m.idMap[id] then - m.idMap[id] = setmetatable({}, { __mode = 'k' }) + m.idMap[id] = setmetatable({}, wkmt) end m.idMap[id][co] = true end @@ -85,6 +86,7 @@ function m.close(id) if not map then return end + m.idMap[id] = nil for co in pairs(map) do if coroutine.status(co) == 'suspended' then map[co] = nil -- cgit v1.2.3