Library task

This is exported from the core library, which means you don't need to import it.

Interfaces

A task.

Functions

Returns the object for the current task.
Deprecated: Use Task.current instead.

task code/Lambda --name/string="User task" --background/bool=null -> Task
Creates a new user task.
Calls code in a new task.
If the background flag is set, then the new task will not block termination. The background task flag is passed on to sub-tasks.

yield -> none
Voluntarily yields control of the CPU to other tasks.
Advanced
The Toit programming language is cooperatively scheduled, so it is important to place yields in long running loops if other tasks should get an opportunity to run.