FixTask Documentation

Back to summary

import "task/task";

Task class

Task represent a handle to a thread. Each task has own heap and allows communication between threads by sending messages.

Functions

static function create(func, params): Task
static function create(script_name: String, func_name: String, params): Task
static function create(script_name: String, func_name: String, params, load_scripts: Boolean): Task
Creates a new task using the given script and function name (or just a function handle). Optionally you can allow to load additional scripts dynamically (when sending messages with function references to not loaded code).
In the SDK the script name should be a constant string unless the token processing is disabled. You can however specify additional main scripts when building to allow for dynamic usage.
function send(msg)
Sends message to the task.
function receive(): Dynamic
function receive_wait(timeout: Integer): Dynamic
Receieves message from the task. Optionally you can provide a timeout in milliseconds (0 for no waiting, negative value for infinite waiting). In case the timeout has been reached the function returns null.

Communication with parent task

static function send(msg)
Sends message to parent thread (task handle).
static function receive(): Dynamic
static function receive_wait(timeout: Integer): Dynamic
Receives a message from parent thread (task handle). Optionally you can provide a timeout in milliseconds (0 for no waiting, negative value for infinite waiting). In case the timeout has been reached the function returns null.

Miscellaneous

static function get(): Task
Returns the task handle for current task. Returns null if the current thread wasn't created as a task.
static function sleep(amount: Integer)
Sleeps current thread for given amount of milliseconds.