diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-11-02 14:59:45 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-11-02 14:59:45 +0800 |
commit | 98c4293062d0e2ef0e7a80179fd27ea586094bcf (patch) | |
tree | e8b1919b7c0886c5297ad0c41fd5938a15f2ed68 /script/pub/pub.lua | |
parent | 07d37e7b5d4fd1841dbc3fdfb5b17759f2f79baf (diff) | |
download | lua-language-server-98c4293062d0e2ef0e7a80179fd27ea586094bcf.zip |
shelve
Diffstat (limited to 'script/pub/pub.lua')
-rw-r--r-- | script/pub/pub.lua | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/script/pub/pub.lua b/script/pub/pub.lua index 9733846a..5bbb381c 100644 --- a/script/pub/pub.lua +++ b/script/pub/pub.lua @@ -66,8 +66,12 @@ function m.recruitBraves(num, privatePad) } end if privatePad and not m.prvtPad[privatePad] then - thread.newchannel('private:' .. privatePad) - m.prvtPad[privatePad] = thread.channel('private:' .. privatePad) + thread.newchannel('req:' .. privatePad) + thread.newchannel('res:' .. privatePad) + m.prvtPad[privatePad] = { + req = thread.channel('req:' .. privatePad), + res = thread.channel('res:' .. privatePad), + } end end @@ -77,7 +81,7 @@ function m.pushTask(info) return false end if m.prvtPad[info.name] then - m.prvtPad[info.name]:push(info.name, info.id, info.params) + m.prvtPad[info.name].req:push(info.name, info.id, info.params) else taskPad:push(info.name, info.id, info.params) end @@ -146,6 +150,19 @@ function m.task(name, params, callback) return m.pushTask(info) end +function m.reciveFromPad(pad) + local suc, id, name, result = pad:pop() + if not suc then + return false + end + if type(name) == 'string' then + m.popReport(m.braves[id], name, result) + else + m.popTask(m.braves[id], name, result) + end + return true +end + --- 接收反馈 function m.recieve(block) if block then @@ -157,14 +174,18 @@ function m.recieve(block) end else while true do - local suc, id, name, result = waiter:pop() - if not suc then - break + local ok + if m.reciveFromPad(waiter) then + ok = true end - if type(name) == 'string' then - m.popReport(m.braves[id], name, result) - else - m.popTask(m.braves[id], name, result) + for _, pad in pairs(m.prvtPad) do + if m.reciveFromPad(pad.res) then + ok = true + end + end + + if not ok then + break end end end |