# `ExQuality.Printer`
[🔗](https://github.com/riddler/ex_quality/blob/v0.15.0/lib/ex_quality/printer.ex#L1)

Serializes output from parallel stages to prevent interleaving.

Each stage calls `print_result/1` when complete, which acquires
a lock and prints the entire summary atomically. This ensures
that if multiple stages complete simultaneously, their output
won't be interleaved.

## Usage

    {:ok, _pid} = ExQuality.Printer.start_link()

    # From multiple parallel tasks:
    ExQuality.Printer.print_result(result)

    ExQuality.Printer.stop()

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `print_message`

```elixir
@spec print_message(String.t()) :: :ok
```

Prints a simple message atomically.

A stage reporting progress may also be run on its own, outside a parallel
run, so a message printed with no printer started goes straight to the shell
rather than failing: there is nothing to serialize against.

# `print_result`

```elixir
@spec print_result(ExQuality.Stage.result()) :: :ok
```

Prints a stage result atomically.

Blocks until any concurrent print operation completes, then prints the full
result without interruption. The sequential phases of a run print their
results before there is a printer to serialize against, so a result printed
with no printer started goes straight to the shell.

# `start_link`

```elixir
@spec start_link(keyword()) :: Agent.on_start()
```

Starts the printer agent.

# `stop`

```elixir
@spec stop() :: :ok
```

Stops the printer agent.

---

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