diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-24 10:06:09 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-24 10:06:09 +0800 |
commit | 6cf50a3fdfe50baebdd2888b549c2238f35f0051 (patch) | |
tree | b8b5459802fce548d51eaf398d2c300f8af73a00 /server-beta/src/brave | |
parent | e3c493e3cd4954ac3f47e455025cc2922ab10099 (diff) | |
download | lua-language-server-6cf50a3fdfe50baebdd2888b549c2238f35f0051.zip |
附加子线程
Diffstat (limited to 'server-beta/src/brave')
-rw-r--r-- | server-beta/src/brave/brave.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server-beta/src/brave/brave.lua b/server-beta/src/brave/brave.lua index 93a93142..08909074 100644 --- a/server-beta/src/brave/brave.lua +++ b/server-beta/src/brave/brave.lua @@ -4,12 +4,21 @@ local thread = require 'bee.thread' local m = {} m.type = 'brave' m.ability = {} +m.queue = {} --- 注册成为勇者 function m.register(id) m.taskpad = thread.channel('taskpad' .. id) m.waiter = thread.channel('waiter' .. id) m.id = id + + if #m.queue > 0 then + for _, info in ipairs(m.queue) do + m.waiter:push(info.name, info.params) + end + end + m.queue = nil + m.start() end @@ -20,7 +29,14 @@ end --- 报告 function m.push(name, params) - m.waiter:push(name, params) + if m.waiter then + m.waiter:push(name, params) + else + m.queue[#m.queue+1] = { + name = name, + params = params, + } + end end --- 开始找工作 |