pool

Generated by tinox doc

A generic object pool (Pool<T>) that recycles a bounded number of expensive-to-create objects: acquire() reuses a released object or creates a new one via a factory callback (up to maxSize), release() returns it to the pool for reuse.

Object pool

import tinox.core.pool;

class Main
{
    fnc main() -> Int32
    {
        let connections: Pool<String> = Pool<String>::newWithFactory(5, \-> "new-connection");

        let c1: String = Pool::acquire(connections);
        println("acquired: " + c1);
        Pool::release(connections, c1);
        return 0;
    }
}