scala> val pool = Pool(4, () =>newObject)
pool: io.github.andrebeat.pool.SimplePool[Object] = _
scala> val lease = pool.acquire()
lease: io.github.andrebeat.pool.Lease[Object] = _
scala> lease.release()
Additionally, in order to avoid manually releasing the lease after its used,
you can use the use method on the lease:
scala> val pool = Pool(4, () =>newObject)
pool: io.github.andrebeat.pool.SimplePool[Object] = _
scala> val lease = pool.acquire()
lease: io.github.andrebeat.pool.Lease[Object] = _
scala> lease(println) // the lease is released automatically after its used
java.lang.Object@7970d6d
This library provides classes for dealing with object pooling that allow:
Overview
In order create a new io.github.andrebeat.pool.Pool the constructor method should be used like so
Additionally, in order to avoid manually releasing the lease after its used, you can use the
use
method on the lease: