Parameter Type Required Description fnc function✔ The function that the task will execute. It can have special EventLoop calls like await, sleep, call_soon... args table✔ A table (with no associative members) to set as the arguments. Can have multiple items. obj table✕ The table to turn into a Task. Creates a new instance of Task: a function that can be run by an EventLoop
If you await a Task, it will return the raw function returned values.
If you safely await it, it might return nil, and you need to check its error manually.
Returns:
Type Description TaskThe task object. Table structure:
{ arguments = {}, -- The arguments to give the function the next time Task:run is executed. coro = coroutine_function, -- The coroutine wrapping the task function. futures = {}, -- A list of futures to set the result after the task is done. futures_index = 0, -- The futures list pointer stop_error_propagation = false, -- Whether to stop the error propagation or not error = false or string, -- The error, if any done = false, -- Whether the task is done or not cancelled = false, -- Whether the task is cancelled or not timer = nil or Timer, -- nil if the task is not scheduled, a Timer object otherwise. ran_once = false, -- Whether the task did run (or at least partially run) _scheduled = false, -- Whether the task is scheduled or not (in EventLoop.tasks) _is_error_handler = false -- Whether the task is the error handler or not }
Parameter Type Required Description loop EventLoop✔ The EventLoop executing await Throws an error if the Task can't be awaited.
Parameter Type Required Description loop EventLoop✔ The EventLoop executing await Returns whether the task awaiting this one needs to be paused or not
Returns:
Type Description booleanIf the task awaiting needs to be paused or not
Parameter Type Required Description loop EventLoop✔ The EventLoop executing await Schedules this task, pauses the awaiting one, and returns once the result is done.
Returns:
Type Description mixedThe returned value.
Cancels the task, and if it is awaiting something, cancels the awaiting object too.
Parameter Type Required Description loop EventLoop✔ The loop that will run this part of the task Runs the task function
Parameter Type Required Description future Future✔ The future object. Can be a variant too. index int✕ The index given to the future object (used only with FutureSemaphore) Adds a future that will be set after the task runs.
Parameter Type Required Description fnc function✔ The function A decorator function that will create a new task object with the function passed it everytime it is called.
Returns:
Type Description functionThe wrapper.
