aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/core/installer/context.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-16 01:43:09 +0200
committerGitHub <noreply@github.com>2022-04-16 01:43:09 +0200
commitc472f3ea46a5dd5f62bb12b5857e779ae0d74dc5 (patch)
tree0956a0e6f3b931921563eae6265abd3bad481d9b /lua/nvim-lsp-installer/core/installer/context.lua
parentrun autogen_metadata.lua (diff)
downloadmason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar
mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.gz
mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.bz2
mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.lz
mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.xz
mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.zst
mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.zip
fix(async): slightly better support for nested coroutine contexts (#600)
* fix(async): only dispatch first failure in a.wait_all * add InstallContext:run_concurrently This is needed due to how multiple coroutine contexts are used in a hierchical structure, and the async coroutine dispatcher loses this hierchical context inside callback functions invoked via FFI (I… assume?).
Diffstat (limited to 'lua/nvim-lsp-installer/core/installer/context.lua')
-rw-r--r--lua/nvim-lsp-installer/core/installer/context.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/core/installer/context.lua b/lua/nvim-lsp-installer/core/installer/context.lua
index 5705fa41..f97f334f 100644
--- a/lua/nvim-lsp-installer/core/installer/context.lua
+++ b/lua/nvim-lsp-installer/core/installer/context.lua
@@ -4,6 +4,8 @@ local fs = require "nvim-lsp-installer.core.fs"
local path = require "nvim-lsp-installer.path"
local platform = require "nvim-lsp-installer.platform"
local receipt = require "nvim-lsp-installer.core.receipt"
+local installer = require "nvim-lsp-installer.core.installer"
+local a = require "nvim-lsp-installer.core.async"
---@class ContextualSpawn
---@field cwd CwdManager
@@ -139,4 +141,17 @@ function InstallContext:promote_cwd()
self.cwd:set(self.destination_dir)
end
+---Runs the provided async functions concurrently and returns their result, once all are resolved.
+---This is really just a wrapper around a.wait_all() that makes sure to patch the coroutine context before creating the
+---new async execution contexts.
+---@async
+---@param suspend_fns async fun(ctx: InstallContext)[]
+function InstallContext:run_concurrently(suspend_fns)
+ return a.wait_all(vim.tbl_map(function(suspend_fn)
+ return function()
+ return installer.run_installer(self, suspend_fn)
+ end
+ end, suspend_fns))
+end
+
return InstallContext