Expand description
The pool: a Send blueprint you build once and clone onto every thread, and
the strictly thread-local pool it stamps out on each.
Pool holds nothing hot — only the manager, the configuration, a shutdown
flag and a registry of per-thread metrics blocks, behind one Arc. Cloning it
is an Arc bump. The connections, the idle list and the slot count all live in
the LocalPool that Pool::local creates on a thread: Rc and Cell, no
lock and no atom on the hot path, never Send. The type system then stops a
connection — bound to one ring — from ever leaving its thread.
§Metrics across threads
Each LocalPool owns one [Metrics] block and registers a clone of it with
the Pool. Only the owning thread ever writes its block, so the counters are
plain relaxed atomics with no cross-thread contention. Pool::state and
Pool::statistics lock the registry — a cold path — and sum every block to
give a process-wide view; LocalPool::state and LocalPool::statistics
read only this thread’s block.
Structs§
- Local
Pool - One thread’s pool, created by
Pool::local. - Pool
- A blueprint for per-thread pools: build it once, clone it onto each compio
thread you spawn, and call
localthere. - Pooled
Connection - A connection checked out of its
LocalPool. Derefs to the connection; dropping it runshas_brokenand either returns the connection to this thread’s idle list or drops it and frees the slot. If the pool has beenclosed, the connection is always dropped. - State
- A snapshot of live connection counts. From
LocalPool::stateit is one thread’s; fromPool::stateit is the sum across every thread. - Statistics
- Cumulative counters over a pool’s life. From
LocalPool::statisticsit is one thread’s; fromPool::statisticsit is the sum across every thread.