> ## Documentation Index
> Fetch the complete documentation index at: https://acme-c84a37e5.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Concurrency

> Concurrency control and batch execution modes

## Options

* `concurrency`: limit of simultaneous tasks
* `mode`: in `all`, `settle` or `fail-fast`

## `all` with limit

```typescript theme={null}
import { all } from "tryo";

const tasks = Array.from({ length: 10 }, (_, i) => async () => i);

const results = await all<number>(tasks, { concurrency: 3 });
```

## `fail-fast`

Stops the start of new tasks on the first error.

```typescript theme={null}
const results = await all<number>(tasks, {
  concurrency: 4,
  mode: "fail-fast",
});
```

Unstarted tasks remain in `skipped` state.

## `allOrThrow`

Throws on the first error and respects `concurrency`.

```typescript theme={null}
import { allOrThrow } from "tryo";

const data = await allOrThrow<number>(tasks, { concurrency: 2 });
```
