metis.async

A basic system for running multiple tasks at the same time.

One creates asynchronous tasks with async, whose result can be fetched with await.

Usage

async(f)Run a function in the background.
await(task)Wait for a task to finish.
run()Start the task queue.
async(f)Source

Run a function in the background.

Parameters

  1. f function() The function to run

Returns

  1. Task The generated task.
await(task)Source

Wait for a task to finish.

Parameters

  1. task Task The task to await on.

Returns

  1. ... The result of running this task.

Throws

  • If the underlying task errored.

  • If the "terminate" event was found.

run()Source

Start the task queue. This can either be given a function (which should run the main body of your function), or called as the last statement in your program.

Tasks will not be run until this function is called, so you should not await (or ideally create any tasks) until the queue is created.

Returns

  1. The result of the given function.

Throws

  • If the underlying function throws.

  • If trying to run multiple task queues at once.

Types

Task

An asynchronous task.

Task.await(task)Source

Wait for a task to finish.

Parameters

  1. task Task The task to await on.

Returns

  1. ... The result of running this task.

Throws

  • If the underlying task errored.

  • If the "terminate" event was found.