nvim_runtime_lua

uv.uv_async_t

uv_async_t - Async handle

[uv_handle_t][] functions also apply.

Async handles allow the user to "wakeup" the event loop and get a callback called from another thread.

local async
async = uv.new_async(function()
  print("async operation ran")
  async:close()
end)

async:send()

Methods1

function uv_async_t.send(...: uv.threadargs) -> (success 0 | nil, err nil | string, err_name uv.error_name | nil)

Wakeup the event loop and call the async handle's callback. Note: It's safe to call this function from any thread. The callback will be called on the loop thread. Warning: libuv will coalesce calls to uv.async_send(async), that is, not every call to it will yield an execution of the callback. For example: if uv.async_send() is called 5 times in a row before the callback is called, the callback will only be called once. If uv.async_send() is called again after the callback was called, it will be called again.