Skip to content

Commit 3767771

Browse files
committed
每个线程只进行一次update
1 parent d119258 commit 3767771

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

script/brave/work.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ brave.on('loadProtoBySocket', function (param)
5454

5555
function lsmaster:on_data(data)
5656
lsclient:write(data)
57-
net.update()
57+
--net.update()
5858
end
5959

6060
while true do

script/proto/proto.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ function m.send(data)
5555
io.write(buf)
5656
elseif m.mode == 'socket' then
5757
m.client:write(buf)
58-
net.update()
5958
end
6059
end
6160

@@ -258,15 +257,9 @@ function m.listen(mode, socketPort)
258257
}
259258
m.client = dummyClient
260259

261-
local t = timer.loop(0.1, function ()
262-
net.update()
263-
end)
264-
265260
function server:on_accepted(client)
266-
t:remove()
267261
m.client = client
268262
client:write(dummyClient.buf)
269-
net.update()
270263
end
271264

272265
pub.task('loadProtoBySocket', {

script/service/service.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ local ws = require 'workspace'
1212
local time = require 'bee.time'
1313
local fw = require 'filewatch'
1414
local furi = require 'file-uri'
15+
local net = require 'service.net'
1516

1617
require 'jsonc'
1718
require 'json-beautify'
@@ -168,6 +169,7 @@ function m.eventLoop()
168169
end
169170

170171
local function doSomething()
172+
net.update()
171173
timer.update()
172174
pub.step(false)
173175
if await.step() then
@@ -180,7 +182,7 @@ function m.eventLoop()
180182
local function sleep()
181183
idle()
182184
for _ = 1, 10 do
183-
thread.sleep(100)
185+
net.update(100)
184186
if doSomething() then
185187
return
186188
end

0 commit comments

Comments
 (0)