Language: Python · Sphere: programming · Category: Performance
Thread-safe object pool for reusing expensive-to-create resources.
Manages a bounded pool of objects built by a factory and checked by a validator: it prefills to min_size, hands out live objects (creating up to max_size on demand), validates on acquire and return, reaps idle/invalid objects, and blocks acquirers until one frees when the cap is reached. Use it for connections or other costly handles. Guarantees (self-test oracle): prefill count is exact, stock is reused without new creation, a request past max_size times out, invalidation shrinks the pool, and idle objects past the timeout are discarded and rebuilt fresh.
When it runs, object pool allocator guarantees made['n'] == 2; pool.size() == 2 and pool.available() == 2; made['n'] == 2 (proven by run).
Checkable constraints:
made['n'] == 2pool.size() == 2 and pool.available() == 2id(po2.obj) in prefilledmade['n'] == 2made['n'] == 4 and pool.size() == 4again.obj is freed.objpool.size() == 3made['n'] == before
- Green-run: ✓ passes (re-run under the extractor's gate)
- Constraint strength: recovery (truth-pinned)
- Independent oracle: — none yet (green-run candidate; not an axiom under the frozen ruler)
- Peer review: unreviewed
△ AURA Pattern Library — © Reality Optimizer