ConditionalHotswapRefConstructor

trait ConditionalHotswapRefConstructor[F[_], I, R] extends HotswapRefConstructor[F, I, R]

Adds functionality to HotswapRefConstructor to check whether input I has changed and only if it has, swap the current value of R with a new cats.effect.kernel.Resource.

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

Value members

Concrete methods

def maybeSwapWith(next: I): F[Boolean]

Conditionally swap R using I. If next matches the current value of I then do not swap.

Conditionally swap R using I. If next matches the current value of I then do not swap.

Use swapWith to force reinitialization of R.

Note that the reference to I is relinquished before swapWith is called, so that we don't get blocked.

Returns:

boolean result of conditional swap, true if R has been swapped false if it has not been swapped.

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 accessI: Resource[F, I]

Access the current input value I on its own

Access the current input value I on its own

Inherited from:
HotswapRefConstructor
def accessR: Resource[F, R]

Access the current resource value R on its own

Access the current resource value R on its own

Inherited from:
HotswapRefConstructor
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
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 from:
HotswapRefConstructor