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
Successthat corresponds to return type andFailuredescribing an error type (caused by thrown exceptions). Third type varibaleMessagedescribes type of messages this task may produce.Please note that that TS does not really check exceptions so
Failuretype can not be guaranteed. Yet, we find them more practical that omitting them as TS does forPromisetypes.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
Controlinstructions yield by generator. When scheduler getscontextinstruction it will resume generator with a handle that can be used to resume running generator after it is suspended. Whensuspendinstruction is received scheduler will suspend execution until it is resumed by queueing it from the outside event.