Task is a unit of computation that runs concurrently, a light-weight
process (in Erlang terms). You can spawn bunch of them and provided
cooperative scheduler will interleave their execution.
Tasks have three type variables first two describing result of the
computation Success that corresponds to return type and Failure
describing an error type (caused by thrown exceptions). Third type
varibale Message describes type of messages this task may produce.
Please note that that TS does not really check exceptions so Failure
type can not be guaranteed. Yet, we find them more practical that omitting
them as TS does for Promise types.
Our tasks are generators (not the generator functions, but what you get
invoking them) that are executed by (library provided) provided scheduler.
Scheduler recognizes two special Control instructions yield by generator.
When scheduler gets context instruction it will resume generator with
a handle that can be used to resume running generator after it is suspended.
When suspend instruction is received scheduler will suspend execution until
it is resumed by queueing it from the outside event.
Task is a unit of computation that runs concurrently, a light-weight process (in Erlang terms). You can spawn bunch of them and provided cooperative scheduler will interleave their execution.
Tasks have three type variables first two describing result of the computation
Success
that corresponds to return type andFailure
describing an error type (caused by thrown exceptions). Third type varibaleMessage
describes type of messages this task may produce.Please note that that TS does not really check exceptions so
Failure
type can not be guaranteed. Yet, we find them more practical that omitting them as TS does forPromise
types.Our tasks are generators (not the generator functions, but what you get invoking them) that are executed by (library provided) provided scheduler. Scheduler recognizes two special
Control
instructions yield by generator. When scheduler getscontext
instruction it will resume generator with a handle that can be used to resume running generator after it is suspended. Whensuspend
instruction is received scheduler will suspend execution until it is resumed by queueing it from the outside event.