AsyncResourcePool

korolev.effect.AsyncResourcePool
See theAsyncResourcePool companion object
class AsyncResourcePool[F[_], T](name: String, factory: => F[T], currentNanos: () => F[Long], maxCount: Int, maxIdleTime: FiniteDuration)(implicit evidence$1: Effect[F], evidence$2: Close[F, T], reporter: Reporter)

Asynchronous non-blocking resource pool with lifetime control.

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Type members

Classlikes

case class PoolItem(idle: Long, value: T)

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
case class PoolState(total: Int, items: List[PoolItem], cbs: List[Promise], closedItems: TreeSet[Int], disposeCbs: List[DisposePromise], disposed: Boolean)

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Types

type DisposePromise = () => Unit
type Promise = () => Borrow[F, T]

Value members

Concrete methods

def borrow(): F[Borrow[F, T]]

Borrow item from the pool.

Borrow item from the pool.

  1. Borrow one of idle items if it exists
  2. Otherwise try to creates one using factory
  3. If maxCount is reached, waits until one of borrowed items would given back

Attributes

def cleanup(): F[Int]
def dispose(): F[Unit]
def onDispose(): F[Unit]

For debug purposes only

For debug purposes only

Attributes

def use[R](f: T => F[R]): F[R]