From 564451b82ccb973a8a20a88794318db47b0c0a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 13 Mar 2019 18:22:50 +0800 Subject: =?UTF-8?q?=E6=8A=8Asource=E6=B5=8B=E8=AF=95=E6=8C=AA=E5=88=B0serv?= =?UTF-8?q?ice=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service.lua | 11 +++++++++++ server/src/vm/vm.lua | 14 +++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/server/src/service.lua b/server/src/service.lua index ba45f9f4..8b07aa33 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -561,6 +561,17 @@ function mt:onTick() alive, dead )) + + --TODO source测试 + local total = 0 + local alive = 0 + for source in pairs(CachedSource) do + if not source:isDead() then + alive = alive + 1 + end + total = total + 1 + end + log.debug(('CachedSource: %d/%d'):format(alive, total)) end end diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 000d0284..4a0250f1 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -8,7 +8,8 @@ local buildGlobal = require 'vm.global' local createMulti = require 'vm.multi' local libraryBuilder = require 'vm.library' -local CachedSource = setmetatable({}, { __mode = 'kv' }) +-- TODO source测试 +rawset(_G, 'CachedSource', setmetatable({}, { __mode = 'kv' })) local mt = {} mt.__index = mt @@ -1080,7 +1081,7 @@ function mt:instantSource(source) if sourceMgr.instant(source) then source:setUri(self:getUri()) self.sources[#self.sources+1] = source - --CachedSource[source] = true + CachedSource[source] = true end return source end @@ -1186,14 +1187,5 @@ return function (ast, lsp, uri) if not suc then return nil, res end - --local total = 0 - --local alive = 0 - --for source in pairs(CachedSource) do - -- if not source:isDead() then - -- alive = alive + 1 - -- end - -- total = total + 1 - --end - --log.debug(('CachedSource: %d/%d'):format(alive, total)) return res end -- cgit v1.2.3