> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sifr.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Concurrency Overview

> Understand Sifr's structured concurrency model: async await, scoped tasks, cancellation, ownership at task boundaries, and parallel CPU work.

Sifr's concurrency model is structured: every task belongs to an explicit scope, and the scope cannot exit until its children have finished or been cancelled. There are no fire-and-forget tasks, no global event-loop object, and no hidden task registry.

The compiler applies the same safety model at concurrency boundaries that it applies everywhere else. Values crossing task, thread, or process boundaries must be owned and sendable. Mutable borrows and lock guards stay scoped.

## Read This Section In Order

<CardGroup cols={2}>
  <Card title="Async and Await" icon="timer" href="/concurrency/async-and-await">
    Define async functions, await suspension points, and understand how Sifr differs from Python `asyncio`.
  </Card>

  <Card title="Structured Tasks" icon="workflow" href="/concurrency/structured-tasks">
    Use scopes, spawned tasks, `gather`, `select`, and `TaskGroup`.
  </Card>

  <Card title="Cancellation and Timeouts" icon="clock-alert" href="/concurrency/cancellation-and-timeouts">
    Bound work, observe cancellation evidence, and rely on cleanup before cancellation is surfaced.
  </Card>

  <Card title="Ownership Across Tasks" icon="shield-check" href="/concurrency/ownership-across-tasks">
    Learn what can cross task boundaries and why borrowed values cannot escape.
  </Card>

  <Card title="Parallel Work" icon="microchip" href="/concurrency/parallel-work">
    Offload CPU-heavy maps and worker pools with `sifr.parallel`.
  </Card>

  <Card title="Concurrency API" icon="library" href="/concurrency/api">
    Reference for `sifr.task`, `sifr.sync`, `sifr.parallel`, process helpers, signals, and cleanup.
  </Card>
</CardGroup>

## What Is Different From Python

Python `asyncio` exposes event loops, detached tasks, and ambient task registries. Sifr does not. Sifr makes the lifetime of concurrent work part of the source program.

| Python habit                           | Sifr model                                                       |
| -------------------------------------- | ---------------------------------------------------------------- |
| Create a background task and forget it | Spawn inside a scope that owns the child                         |
| Reach for a global event loop          | Use `async def`, `await`, and `sifr.task` scopes                 |
| Share mutable objects between tasks    | Move owned values, use channels, or use explicit sync primitives |
| Treat cancellation as ambient          | Observe typed cancellation or timeout evidence                   |
| Run CPU work on the event loop         | Use `sifr.parallel` for owned, sendable data                     |

## Related Pages

<CardGroup cols={2}>
  <Card title="Ownership and Mutability" icon="refresh-cw" href="/language/ownership">
    Review `mut`, `own`, `own mut`, and borrowed-value escape rules.
  </Card>

  <Card title="Error Handling" icon="triangle-alert" href="/language/error-handling">
    See how async functions report typed errors with `Result`.
  </Card>

  <Card title="Networking" icon="radio" href="/stdlib/networking">
    Use async TCP, HTTP, TLS, and URL helpers.
  </Card>

  <Card title="Error Codes" icon="scan-search" href="/diagnostics/error-codes">
    Look up `SIFR-ASYNC-*` and task-boundary ownership diagnostics.
  </Card>
</CardGroup>
