SingleThreadedAsyncObjectPool

com.github.mauricio.async.db.pool.SingleThreadedAsyncObjectPool
See theSingleThreadedAsyncObjectPool companion object
class SingleThreadedAsyncObjectPool[T](factory: ObjectFactory[T], configuration: PoolConfiguration) extends AsyncObjectPool[T]

Implements an com.github.mauricio.async.db.pool.AsyncObjectPool using a single thread from a fixed executor service as an event loop to cause all calls to be sequential.

Once you are done with this object remember to call it's close method to clean up the thread pool and it's objects as this might prevent your application from ending.

Attributes

T

type of the object this pool holds

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Concise view

Value members

Concrete methods

def availables: Iterable[T]
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

override def finalize(): Unit

Called by the garbage collector on the receiver object when there are no more references to the object.

Called by the garbage collector on the receiver object when there are no more references to the object.

The details of when and if the finalize method is invoked, as well as the interaction between finalize and non-local returns and exceptions, are all platform dependent.

Attributes

Note:

not specified by SLS as a member of AnyRef

Definition Classes
Object
def giveBack(item: T): Future[AsyncObjectPool[T]]

Returns an object to the pool. The object is validated before being added to the collection of available objects to make sure we have a usable object. If the object isn't valid it's discarded.

Returns an object to the pool. The object is validated before being added to the collection of available objects to make sure we have a usable object. If the object isn't valid it's discarded.

Attributes

def inUse: Iterable[T]
def isClosed: Boolean
def isFull: Boolean
def queued: Iterable[Promise[T]]
def take: Future[T]

Asks for an object from the pool, this object should be returned to the pool when not in use anymore.

Asks for an object from the pool, this object should be returned to the pool when not in use anymore.

Attributes

Inherited 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.

Attributes

f

function that uses the object

Returns:

f wrapped with take and giveBack

Inherited from:
AsyncObjectPool