From 7e10ca9e3f60c5a108ee3d9bccf9c42da3d74c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 22 Oct 2019 14:46:29 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=84=E8=AF=BB=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/pub/pub.lua | 2 +- server-beta/src/workspace/workspace.lua | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'server-beta/src') diff --git a/server-beta/src/pub/pub.lua b/server-beta/src/pub/pub.lua index cf1eb955..f6db6d4f 100644 --- a/server-beta/src/pub/pub.lua +++ b/server-beta/src/pub/pub.lua @@ -132,7 +132,7 @@ function m.task(name, params) end --- 发布同步任务,如果任务进入了队列,会返回执行器 ----|通过 jumpQueue 可以插队 +--- 通过 jumpQueue 可以插队 ---@parma name string ---@param params any ---@param callback function diff --git a/server-beta/src/workspace/workspace.lua b/server-beta/src/workspace/workspace.lua index efe2f1cf..70334134 100644 --- a/server-beta/src/workspace/workspace.lua +++ b/server-beta/src/workspace/workspace.lua @@ -86,6 +86,8 @@ function m.preload() if not m.uri then return end + local max = 0 + local read = 0 log.info('Preload start.') local ignore = m.getIgnoreMatcher() @@ -111,22 +113,21 @@ function m.preload() if not files.isLua(uri) then return end + max = max + 1 pub.syncTask('loadFile', uri, function (text) + read = read + 1 log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #text / 1000.0)) files.setText(uri, text) end) end) + log.info(('Found %d files.'):format(max)) while true do - local count = 0 - for _, file in pairs(files.fileMap) do - if file.compiling then - task.sleep(0.1) - goto CONTINUE - end - count = count + 1 + log.info(('Loaded %d/%d files'):format(read, max)) + if read < max then + task.sleep(0.1) + goto CONTINUE end - log.info(('Preloaded %d files.'):format(count)) break ::CONTINUE:: end -- cgit v1.2.3