AutoUpdatingVar

ca.dvgi.periodic.AutoUpdatingVar
abstract class AutoUpdatingVar[U[_], R[_], T](updateVar: => U[T], updateInterval: UpdateInterval[T], updateAttemptStrategy: UpdateAttemptStrategy, handleInitializationError: PartialFunction[Throwable, U[T]], varNameOverride: Option[String])(implicit ct: ClassTag[T]) extends AutoCloseable

A variable that updates itself. latest can be called from multiple threads, which are all guaranteed to get the latest var.

An AutoUpdatingVar attempts to get the variable immediately upon class instantiation. If this fails, there are no further attempts (unless specified via handleInitializationError1), and the effect returned by thereadymethod will complete unsuccesfully. If it succeeds, the effect completes successfully andlatest` can be safely called.

Failed updates other than the first (those that throw an exception) may be retried with various configurations.

A successful update schedules the next update, with an interval that can vary based on the just-updated var.

Value parameters

handleInitializationError

A PartialFunction used to recover from exceptions in the var initialization. If unspecified, the exception will fail the effect returned by ready.

updateAttemptStrategy

Configuration for retrying updates on failure

updateInterval

Configuration for the update interval

updateVar

A thunk to initialize and update the var

varNameOverride

A name for this variable, used in logging. If unspecified, the simple class name of T will be used.

Attributes

Graph
Supertypes
trait AutoCloseable
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def latest: T

Wait for ready to be completed before calling this method.

Wait for ready to be completed before calling this method.

Attributes

Returns

The latest value of the variable. Calling this method is thread-safe.

Throws
UnreadyAutoUpdatingVarException

if there is not yet a value to return

def ready: R[Unit]

Attributes

Returns

An effect which, once successfully completed, signifies that the AutoUpdatingVar has a value, i.e. latest can be called and no exception will be thrown.

Concrete methods

override def close(): Unit

Attributes

Definition Classes
AutoCloseable
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any