Skip to content

Commit e7a4cc6

Browse files
committed
fix cpu usage
1 parent f63375d commit e7a4cc6

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"type": "lua",
2727
"request": "attach",
2828
"stopOnEntry": false,
29-
"address": "127.0.0.1:11414",
29+
"address": "127.0.0.1:11413",
3030
"outputCapture": [
3131
],
3232
"sourceFormat": "string",

script/meta/bee/select.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function selector:event_mod(fd, events, callback) end
3232
function selector:event_del(fd) end
3333

3434
---Wait for events on registered file descriptors
35-
---@param timeout? integer # Timeout in milliseconds (ms), -1 for infinite wait, default 0 (non-blocking)
35+
---@param timeout integer # Timeout in milliseconds (ms), -1 for infinite wait
3636
---@return fun():any, integer # Iterator function returning (callback_data, event_flags)
3737
function selector:wait(timeout) end
3838

script/service/service.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,13 @@ function m.eventLoop()
168168
end
169169
end
170170

171+
local lastNetUpdateTime = 0
171172
local function doSomething()
172-
net.update()
173+
local now = time.monotonic()
174+
if now - lastNetUpdateTime >= 100 then
175+
net.update()
176+
lastNetUpdateTime = now
177+
end
173178
timer.update()
174179
pub.step(false)
175180
if await.step() then

0 commit comments

Comments
 (0)