HotswapRefConstructor

trait HotswapRefConstructor[F[_], I, R] extends HotswapRef[F, (I, R)]

Use some I to construct R via a provided function, within a HotswapRef.

Use some I to construct R via a provided function, within a HotswapRef.

Calls to swapWith update the value of R within HotswapRef with provided with some I.

Companion
object
trait HotswapRef[F, (I, R)]
class Object
trait Matchable
class Any

Value members

Concrete methods

def accessI: Resource[F, I]

Access the current input value I on its own

Access the current input value I on its own

def accessR: Resource[F, R]

Access the current resource value R on its own

Access the current resource value R on its own

def swapWith(next: I): F[Unit]

Swap R using I using some function of I to cats.effect.kernel.Resource of R, provided at construction time

Swap R using I using some function of I to cats.effect.kernel.Resource of R, provided at construction time

Inherited methods

def access: Resource[F, (I, R)]

Access R safely

Access R safely

Note that access to R is protected by a shared-mode lock via a cats.effect.kernel.Resource scope. A resource R with unreleased locks cannot be finalized and therefore cannot be fully swapped.

Inherited from
HotswapRef
def swap(next: Resource[F, (I, R)]): F[Unit]

Swap the current resource with a new version

Swap the current resource with a new version

This makes use of evalTap on the provided cats.effect.kernel.Resource to ensure the cats.effect.kernel.Ref with R is updated immediately on allocation and may be used by access calls while swap blocks, waiting for the previous cats.effect.kernel.Resource to finalize.

This means that while there is no previous finalization process in progress when this is called, R may be swapped in the holder ref, but will block until all references to R are removed and R is torn down.

A semaphore guarantees that concurrent access to swap will wait while previous resources are finalized.

Inherited from
HotswapRef