async.lua
---@meta async local async = {} ---Wraps the provided function so it can be started in another thread. --- --- Example: --- ```lua --- local a = require("async") --- local u = require("Utils") --- --- function asyncFunction() --- a.wait(u.waitms(500)) --- end --- --- a.sync(asyncFunction)() --- ``` ---@param func function The function to call from the new thread. function async.sync(func) end ---@async ---Calls an async function and waits for it to finish. **Must** be called from async.sync(). --- --- Example: --- ```lua --- local a = require("async") --- local u = require("Utils") --- --- function asyncFunction() --- a.wait(u.waitms(500)) --- a.wait(u.waitms(1000)) --- end --- --- a.sync(asyncFunction)() --- ``` ---@param func any The function to call and wait for its result. ---@return any any The result of the function. function async.wait(func) end ---@async ---Calls multiple async functions and waits for all of them to finish. **Must** be called from async.sync(). --- --- Example: --- ```lua --- local a = require("async") --- local u = require("Utils") --- --- function asyncFunction() --- a.wait_all { --- u.waitms(500), --- u.waitms(1000), --- } --- end --- --- a.sync(asyncFunction)() --- ``` ---@param funcs table The functions to call and wait for. ---@return table table The result of each of the functions as an array. function async.wait_all(funcs) end return async
©2024 Qt 公司版权所有。本文档中包含的文档贡献版权属于各自的业主。提供的文档是根据自由软件基金会发布的《GNU 自由文档许可协议版本 1.3》许可的。Qt 和相关标志是芬兰及其它国家和地区 Qt 公司的商标。所有其他商标均为各自所有者的财产。