Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh committed Nov 11, 2023
1 parent 1bc54f4 commit 78a8b0c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lua/obsidian/async.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ end
---@param pause_fn function(integer)
Executor._join = function(self, timeout, pause_fn)
---@diagnostic disable-next-line: undefined-field
local start_time = uv.uptime()
local start_time = uv.hrtime() / 1000000 -- ns -> ms
local pause_for = 100
if timeout ~= nil then
pause_for = math.min(timeout / 2, pause_for)
end
while self.tasks_pending > 0 or self.tasks_running > 0 do
pause_fn(pause_for)
---@diagnostic disable-next-line: undefined-field
if timeout ~= nil and uv.uptime() - start_time > timeout then
if timeout ~= nil and (uv.hrtime() / 1000000) - start_time > timeout then
return echo.fail "Timeout error from AsyncExecutor.join()"
end
end
Expand Down Expand Up @@ -172,9 +172,9 @@ AsyncExecutor.submit = function(self, fn, callback, ...)
while self.tasks_running >= self.max_workers do
async.util.sleep(20)
end
self.tasks_pending = self.tasks_pending - 1
self.tasks_running = self.tasks_running + 1
end
self.tasks_pending = self.tasks_pending - 1
self.tasks_running = self.tasks_running + 1
return fn(unpack(args))
end, function(...)
self.tasks_running = self.tasks_running - 1
Expand Down

0 comments on commit 78a8b0c

Please sign in to comment.