Easypt

Task

..Root.Task

The Task class represents an asynchronous operation. It runs the function f asynchronously (independently of the main program flow) with its remaining arguments as arguments and p as its parent. It is guaranteed that there are no data races.

Exceptions: Exception thrown in f makes task finished and is propagated through get.

Task type signatures:

Object, Task

Child of:

Root

Signatures:

NativeCallable, Callable, Class

Members:

Example:

import("console");

auto taskA.=(Task(Root, {
    for (auto i.=(0).<, 10, i.++, {
        console.writeLine("A");
    });
    return("Task A ended.");
}));

auto taskB.=(Task(Root, {
    for (auto i.=(0).<, 10, i.++, {
        console.writeLine("B");
    });
    return("Task B ended.");
}));

console.writeLine(taskA.get());
console.writeLine(taskB.get());

Expected output:

A
B
A
B
A
B
A
B
A
B
A
B
A
B
A
B
A
B
A
B
Task A ended.
Task B ended.