io.github.andrebeat

pool

package pool

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

scala> val pool = Pool(4, () => new Object)
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, () => new Object)
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
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. pool
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. abstract class ArrayBlockingQueuePool[A <: AnyRef] extends Pool[A]

    A generic object pooling implementation based on java.util.concurrent.ArrayBlockingQueue.

  2. class ExpiringPool[A <: AnyRef] extends ArrayBlockingQueuePool[A]

    An object pool that creates the objects as needed until a maximum number of objects has been created and automatically evicts objects after they have been idle for a given amount of time.

  3. trait Lease[A <: AnyRef] extends AnyRef

    A lease on an object requested from a io.github.andrebeat.pool.Pool allowing the object to be accessed and then released back to the pool when no longer needed.

  4. trait Pool[A <: AnyRef] extends AnyRef

    A pool of objects that may be leased.

  5. sealed trait ReferenceType extends AnyRef

    An enum-type for Java reference types.

  6. class SimplePool[A <: AnyRef] extends ArrayBlockingQueuePool[A]

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

Value Members

  1. object ExpiringPool

    Object containing factory methods for io.github.andrebeat.pool.ExpiringPool.

  2. object Pool

    Object containing factory methods for io.github.andrebeat.pool.Pool.

  3. object ReferenceType

  4. object SimplePool

    Object containing factory methods for io.github.andrebeat.pool.SimplePool.

Inherited from AnyRef

Inherited from Any

Ungrouped