# `Imp.Tasks`
[🔗](https://github.com/deepfates/imp/blob/v0.18.1/lib/imp/tasks.ex#L176)

Tasks that carry the caller's Imp context.

`async/1` and `async_nolink/1` start a supervised task that runs with the
settings, `Imp.Run` context, telemetry context and `Imp.Deadline` of the
process that started it, so a model call or tool event inside the task
belongs to the caller's run, reads the caller's `Imp.configure/1` and
`Imp.context/2` settings, and has its model requests capped to the caller's
deadline. A plain `Task` does not carry them.

Every such task takes a place in one machine-wide pool bounded by the
`:async_max_workers` setting, and waits for a place when the pool is full.
The caller's deadline does not bound that wait. A host that bounds its own
runs passes `admission: {pool, limit}` to `Imp.Run.start/3` instead.

# `async`

```elixir
@spec async((-&gt; term())) :: Task.t()
```

Starts a linked supervised task that carries the caller's settings, run and
telemetry context.

    iex> task = Imp.context([task_marker: :inside], fn ->
    ...>   Imp.Tasks.async(fn -> Imp.Settings.fetch!(:task_marker) end)
    ...> end)
    iex> Task.await(task)
    :inside

# `async_nolink`

```elixir
@spec async_nolink((-&gt; term())) :: Task.t()
```

Starts an unlinked supervised task that carries the caller's settings, run
and telemetry context. Await it with `Task.yield/2` or `Task.await/2`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
