diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/await.lua | 20 | ||||
-rw-r--r-- | script/proto/proto.lua | 10 |
2 files changed, 15 insertions, 15 deletions
diff --git a/script/await.lua b/script/await.lua index d8e2a9ad..74845fae 100644 --- a/script/await.lua +++ b/script/await.lua @@ -58,10 +58,10 @@ function m.await(callback, ...) if not coroutine.isyieldable() then return callback(...) end - return m.wait(function (waker, ...) + return m.wait(function (resume, ...) m.call(function () - local returnNil <close> = util.defer(waker) - waker(callback()) + local returnNil <close> = util.defer(resume) + resume(callback()) end, ...) end, ...) end @@ -121,12 +121,12 @@ function m.wait(callback, ...) return end local co = coroutine.running() - local waked + local resumed callback(function (...) - if waked then + if resumed then return end - waked = true + resumed = true if coroutine.status(co) ~= 'suspended' then return end @@ -180,15 +180,15 @@ end --- 步进 function m.step() - local waker = m.delayQueue[m.delayQueueIndex] - if waker then + local resume = m.delayQueue[m.delayQueueIndex] + if resume then m.delayQueue[m.delayQueueIndex] = false m.delayQueueIndex = m.delayQueueIndex + 1 local clock = os.clock() - waker() + resume() local passed = os.clock() - clock if passed > 0.1 then - warnStepTime(passed, waker) + warnStepTime(passed, resume) end return true else diff --git a/script/proto/proto.lua b/script/proto/proto.lua index d8538d8f..bc3f41f4 100644 --- a/script/proto/proto.lua +++ b/script/proto/proto.lua @@ -76,8 +76,8 @@ function m.awaitRequest(name, params) } --log.debug('Request', name, #buf) io.stdout:write(buf) - return await.wait(function (waker) - m.waiting[id] = waker + return await.wait(function (resume) + m.waiting[id] = resume end) end @@ -123,8 +123,8 @@ end function m.doResponse(proto) local id = proto.id - local waker = m.waiting[id] - if not waker then + local resume = m.waiting[id] + if not resume then log.warn('Response id not found: ' .. util.dump(proto)) return end @@ -133,7 +133,7 @@ function m.doResponse(proto) log.warn(('Response error [%d]: %s'):format(proto.error.code, proto.error.message)) return end - waker(proto.result) + resume(proto.result) end function m.listen() |