Skip to content

Commit 43e375b

Browse files
committed
跟进修改
1 parent c59bd7f commit 43e375b

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

script/brave/brave.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local channel = require 'bee.channel'
22
local select = require 'bee.select'
3+
local thread = require 'bee.thread'
34

45
local function channel_init(chan)
56
local selector = select.create()
@@ -9,11 +10,14 @@ end
910

1011
local function channel_bpop(ctx)
1112
local selector, chan = ctx[1], ctx[2]
12-
for _ in selector:wait() do
13-
local r = table.pack(chan:pop())
14-
if r[1] == true then
15-
return table.unpack(r, 2)
13+
while true do
14+
for _ in selector:wait() do
15+
local r = table.pack(chan:pop())
16+
if r[1] == true then
17+
return table.unpack(r, 2)
18+
end
1619
end
20+
thread.sleep(10)
1721
end
1822
end
1923

script/meta/bee/thread.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
---@class bee.thread
44
local thread = {}
55

6-
---@param time number
6+
---@param time integer
77
function thread.sleep(time) end
88

99
---@param name string
@@ -15,7 +15,10 @@ function thread.channel(name) end
1515

1616
---@param script string
1717
---@return bee.thread.thread
18-
function thread.thread(script) end
18+
function thread.create(script) end
19+
20+
---@return string?
21+
function thread.errlog() end
1922

2023
---@class bee.thread.channel
2124
local channel = {}

0 commit comments

Comments
 (0)