View
Source.View[+A]
consists of the covariant read-only operations of
Ref.View[A]
.
Source.View[+A]
consists of the covariant read-only operations of
Ref.View[A]
.
Value members
Abstract methods
Blocks until f(get)
is true, in a manner consistent with the current
context. Requires that the predicate be safe to reevaluate, and that
f(x) == f(y)
if x == y
.
Blocks until f(get)
is true, in a manner consistent with the current
context. Requires that the predicate be safe to reevaluate, and that
f(x) == f(y)
if x == y
.
v.await(f)
is equivalent to
atomic { implicit t =>
if (!f(v.get)) retry
}
If you want to wait for a predicate that involves more than one Ref
then use retry
directly.
- Value Params
- f
a predicate that is safe to evaluate multiple times.
Performs an atomic read; equivalent to apply()
.
Performs an atomic read; equivalent to apply()
.
- Returns
the value of the
Ref
as observed by the current context.
Acts like ref.getWith(f)
if there is an active transaction, otherwise
just returns f(get)
.
Acts like ref.getWith(f)
if there is an active transaction, otherwise
just returns f(get)
.
- Value Params
- f
an idempotent function.
- Returns
the result of applying
f
to the value contained inref
.
Returns a Source
that accesses the same memory location as this view.
The returned Source
might be the original reference that was used to
construct this view, or it might be a Source
that is equivalent
(and ==
) to the original.
Returns a Source
that accesses the same memory location as this view.
The returned Source
might be the original reference that was used to
construct this view, or it might be a Source
that is equivalent
(and ==
) to the original.
- Returns
a
Source
that accesses the same memory location as this view.
Acts like ref.relaxedGet(equiv)
if there is an active transaction,
otherwise just returns get
.
Acts like ref.relaxedGet(equiv)
if there is an active transaction,
otherwise just returns get
.
- Value Params
- equiv
an equivalence function that returns true if a transaction that observed the first argument will still complete correctly, where the second argument is the actual value that should have been observed.
- Returns
a value of the
Ref
, not necessary consistent with the rest of the reads performed by the active transaction, if any.
Blocks until f(get)
is true and returns true, or returns false if
the condition does not become true within within the specified timeout.
Blocks until f(get)
is true and returns true, or returns false if
the condition does not become true within within the specified timeout.
v.tryAwait(timeout)(f)
is equivalent to
atomic { implicit t =>
f(v.get) || { retryFor(timeout) ; false }
}
- Value Params
- f
a predicate that is safe to evaluate multiple times.
- timeout
the maximum amount of time to wait, in units of
unit
.- unit
the units in which the timeout is measured, defaulting to milliseconds.
- Returns
true if the predicate was satisfied, false if the wait timed out.
Concrete methods
Performs an atomic read of the value in ref
. If an atomic block is
active (see Txn.findCurrent
) then the read will be performed as part
of the transaction, otherwise it will act as if it was performed inside
a new atomic block. Equivalent to get
.
Performs an atomic read of the value in ref
. If an atomic block is
active (see Txn.findCurrent
) then the read will be performed as part
of the transaction, otherwise it will act as if it was performed inside
a new atomic block. Equivalent to get
.
- Returns
the value of the
Ref
as observed by the current context.