AsyncObjectPool

com.github.mauricio.async.db.pool.AsyncObjectPool
trait AsyncObjectPool[T]

Defines the common interface for async object pools. These are pools that do not block clients trying to acquire a resource from it. Different than the usual synchronous pool, you must return objects back to it manually since it's impossible for the pool to know when the object is ready to be given back.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def close: Future[AsyncObjectPool[T]]

Closes this pool and future calls to take will cause the scala.concurrent.Future to raise an com.github.mauricio.async.db.pool.PoolAlreadyTerminatedException.

Closes this pool and future calls to take will cause the scala.concurrent.Future to raise an com.github.mauricio.async.db.pool.PoolAlreadyTerminatedException.

Attributes

def giveBack(item: T): Future[AsyncObjectPool[T]]

Returns an object taken from the pool back to it. This object will become available for another client to use. If the object is invalid or can not be reused for some reason the scala.concurrent.Future returned will contain the error that prevented this object of being added back to the pool. The object is then discarded from the pool.

Returns an object taken from the pool back to it. This object will become available for another client to use. If the object is invalid or can not be reused for some reason the scala.concurrent.Future returned will contain the error that prevented this object of being added back to the pool. The object is then discarded from the pool.

Attributes

def take: Future[T]

Returns an object from the pool to the callee with the returned future. If the pool can not create or enqueue requests it will fill the returned scala.concurrent.Future with an com.github.mauricio.async.db.pool.PoolExhaustedException.

Returns an object from the pool to the callee with the returned future. If the pool can not create or enqueue requests it will fill the returned scala.concurrent.Future with an com.github.mauricio.async.db.pool.PoolExhaustedException.

Attributes

Returns

future that will eventually return a usable pool object.

Concrete methods

def use[A](f: T => Future[A])(implicit executionContext: ExecutionContext): Future[A]

Retrieve and use an object from the pool for a single computation, returning it when the operation completes.

Retrieve and use an object from the pool for a single computation, returning it when the operation completes.

Value parameters

f

function that uses the object

Attributes

Returns

f wrapped with take and giveBack