summaryrefslogtreecommitdiff
path: root/server-beta/src/pub/brave.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-09-19 19:59:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-09-19 19:59:22 +0800
commit039b11fc0b7387ca5e19b20b33d839d42d3068aa (patch)
tree4443514545c4449365dd5d73f78490d96e8ed24a /server-beta/src/pub/brave.lua
parent2d923e462ace05fdeb3c194a67797e1adca65153 (diff)
downloadlua-language-server-039b11fc0b7387ca5e19b20b33d839d42d3068aa.zip
更新
Diffstat (limited to 'server-beta/src/pub/brave.lua')
-rw-r--r--server-beta/src/pub/brave.lua22
1 files changed, 19 insertions, 3 deletions
diff --git a/server-beta/src/pub/brave.lua b/server-beta/src/pub/brave.lua
index c9fd0afe..7662a39e 100644
--- a/server-beta/src/pub/brave.lua
+++ b/server-beta/src/pub/brave.lua
@@ -5,7 +5,23 @@ local m = {}
m.type = 'pub.brave'
--- 注册成为勇者
-function m:register(id)
- self.taskpad = thread.channel('taskpad' .. id)
- self.waiter = thread.channel('waiter' .. id)
+function m.register(id)
+ m.taskpad = thread.channel('taskpad' .. id)
+ m.waiter = thread.channel('waiter' .. id)
+ m.start()
end
+
+--- 开始找工作
+function m.start()
+ while true do
+ local suc, name, id, params = m.taskpad:pop()
+ if not suc then
+ -- 找不到工作的勇者,只好睡觉
+ thread.sleep(0.01)
+ end
+ local result = require(name)(params)
+ m.waiter:push(id, result)
+ end
+end
+
+return m