diff --git a/doc/nio.txt b/doc/nio.txt index 8bba465..a8cac44 100644 --- a/doc/nio.txt +++ b/doc/nio.txt @@ -96,6 +96,13 @@ Parameters~ Return~ `(any[])` Results of all functions + *nio.current_task()* +`current_task`() + +Get the current running task, if any. +Return~ +`(nio.tasks.Task|nil)` + *nio.first()* `first`({functions}) diff --git a/lua/nio/init.lua b/lua/nio/init.lua index 436863c..4223630 100644 --- a/lua/nio/init.lua +++ b/lua/nio/init.lua @@ -121,6 +121,12 @@ function nio.gather(functions) return sorted end +--- Get the current running task, if any. +---@return nio.tasks.Task|nil +function nio.current_task() + return tasks.current_task() +end + --- Run a collection of async functions concurrently and return the result of --- the first to finish. ---@async