SimplePool

io.github.andrebeat.pool.SimplePool
See theSimplePool companion object
class SimplePool[A <: AnyRef](capacity: Int, referenceType: ReferenceType, _factory: () => A, _reset: A => Unit, _dispose: A => Unit, _healthCheck: A => Boolean) extends ArrayBlockingQueuePool[A]

A simple object pool that creates the objects as needed until a maximum number of objects has been created.

Attributes

Companion
object
Graph
Supertypes
trait Pool[A]
class Object
trait Matchable
class Any

Members list

Type members

Inherited and Abstract classlikes

abstract protected class Item(val r: Ref[A])

Attributes

Inherited from:
ArrayBlockingQueuePool
Supertypes
class Object
trait Matchable
class Any

Value members

Inherited methods

def acquire(): Lease[A]

Acquire a lease for an object blocking if none is available.

Acquire a lease for an object blocking if none is available.

Attributes

Returns

a lease for an object from this pool.

Throws
ClosedPoolException

If this pool is closed.

Inherited from:
Pool
def close(): Unit

Closes this pool, and properly disposes of each pooled object, releasing any resources associated with the pool (e.g. background timer threads).

Closes this pool, and properly disposes of each pooled object, releasing any resources associated with the pool (e.g. background timer threads).

If the pool has already been closed this method does nothing.

Attributes

Inherited from:
Pool
def drain(): Unit

Drains the object pool, i.e. evicts every object currently pooled.

Drains the object pool, i.e. evicts every object currently pooled.

Attributes

Throws
ClosedPoolException

If this pool is closed.

Inherited from:
Pool
def fill(): Unit

Fills the object pool by creating (and pooling) new objects until the number of live objects reaches the pool capacity.

Fills the object pool by creating (and pooling) new objects until the number of live objects reaches the pool capacity.

Attributes

Throws
ClosedPoolException

If this pool is closed.

Inherited from:
Pool
def leased(): Int

Returns the number of leased objects.

Returns the number of leased objects.

The value returned by this method is only accurate when the referenceType is io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only when trying to acquire an object.

Attributes

Returns

the number of leased objects.

Inherited from:
Pool
def live(): Int

Returns the number of live objects, i.e. the number of currently pooled objects plus leased objects.

Returns the number of live objects, i.e. the number of currently pooled objects plus leased objects.

The value returned by this method is only accurate when the referenceType is io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only when trying to acquire an object.

Attributes

Returns

the number of live objects.

Inherited from:
ArrayBlockingQueuePool
def size(): Int

Returns the number of objects in the pool.

Returns the number of objects in the pool.

The value returned by this method is only accurate when the referenceType is io.github.andrebeat.pool.ReferenceType.Strong, since GC-based eviction is checked only when trying to acquire an object.

Attributes

Returns

the number of objects in the pool.

Inherited from:
ArrayBlockingQueuePool
def tryAcquire(atMost: Duration): Option[Lease[A]]

Try to acquire a lease for an object blocking at most until the given duration.

Try to acquire a lease for an object blocking at most until the given duration.

Value parameters

atMost

maximum wait time for the lease to be available.

Attributes

Returns

a lease for an object from this pool if available until the given duration, None otherwise.

Throws
ClosedPoolException

If this pool is closed.

Inherited from:
Pool
def tryAcquire(): Option[Lease[A]]

Try to acquire a lease for an object without blocking.

Try to acquire a lease for an object without blocking.

Attributes

Returns

a lease for an object from this pool if available, None otherwise.

Throws
ClosedPoolException

If this pool is closed.

Inherited from:
Pool

Inherited fields

val _capacity: Int

Attributes

Inherited from:
ArrayBlockingQueuePool