aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lua/mason-core/async/control.lua4
-rw-r--r--lua/mason-core/async/init.lua3
2 files changed, 5 insertions, 2 deletions
diff --git a/lua/mason-core/async/control.lua b/lua/mason-core/async/control.lua
index 2388bce5..30ce982c 100644
--- a/lua/mason-core/async/control.lua
+++ b/lua/mason-core/async/control.lua
@@ -50,7 +50,7 @@ function Permit:forget()
if semaphore.permits > 0 and #semaphore.handles > 0 then
semaphore.permits = semaphore.permits - 1
local release = table.remove(semaphore.handles, 1)
- release(Permit:new(semaphore))
+ release()
end
end
@@ -73,7 +73,7 @@ function Semaphore:acquire()
if self.permits > 0 then
self.permits = self.permits - 1
else
- return a.wait(function(resolve)
+ a.wait(function(resolve)
table.insert(self.handles, resolve)
end)
end
diff --git a/lua/mason-core/async/init.lua b/lua/mason-core/async/init.lua
index 56d86170..03963264 100644
--- a/lua/mason-core/async/init.lua
+++ b/lua/mason-core/async/init.lua
@@ -79,6 +79,9 @@ local function new_execution_context(suspend_fn, callback, ...)
return
end
local ok, promise_or_result = co.resume(thread, ...)
+ if cancelled or not thread then
+ return
+ end
if ok then
if co.status(thread) == "suspended" then
if getmetatable(promise_or_result) == Promise then