# `MishkaCmsCore.Runtime.Handlers.CompileGate`
[🔗](https://github.com/mishka-group/mishka_cms_core/blob/v0.0.1/lib/mishka_cms_core/runtime/handlers/compile_gate.ex#L5)

Per-node concurrency limiter for runtime module compilation.

Compiling is CPU-bound, so allowing more compiles at once than the node has cores only
thrashes the scheduler and the (single) code server — it does NOT add resources. This gate
caps concurrent compiles to `System.schedulers_online()` (one per core, the measured sweet
spot); extra compiles wait in a FIFO queue and start as slots free. So a cold-start burst of
many distinct pages can't saturate the node and stall live requests.

Every compile funnels through `run/1`, called by the one
`MishkaCmsCore.Runtime.Handlers.ModuleCompilerHandler` worker a module has — covering boot,
lazy first-request, and Oban-worker compiles. The callers waiting for that worker hold no slot.

Per-node by design: CPU is a per-node resource, so each node throttles its own compiles with
zero cluster coordination. The limit is overridable via
`config :mishka_cms_core, :compile_gate_limit`.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `limit`

```elixir
@spec limit() :: pos_integer()
```

How many compiles this node runs at once.

# `run`

Run `fun` once a compile slot is free — blocking the caller until one opens — then release the
slot. The holder is monitored, so if `fun` raises or the caller is killed the slot is still
reclaimed (see `handle_info/2`); a slot is never leaked.

# `start_link`

---

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