|
<div>Scala 2.1.5</div>
|
class
Fluid
[ T ]
extends
java.lang.Object with
scala.ScalaObjectvalue
method. New values can be
pushed using the withValue
method.
Values pushed via withValue
only
stay valid while the withValue
's
second argument, a parameterless closure,
executes. When the second argument finishes,
the fluid reverts to the previous value.
Usage of withValue
looks like this:
Each thread gets its own stack of bindings. When a new thread is created, the fluid gets a copy of the stack of bindings from the parent thread, and from then on the bindings for the new thread are independent of those for the original thread.someFluid.withValue(newValue) { // ... code called in here that calls value ... // ... will be given back the newValue ... }
Constructor Summary | |
def
this
( init : T )
|
Def Summary | |
override
|
def
toString
: java.lang.String
|
def
value
: T
Retrieve the current value |
|
def
value_=
( newval : T )
: scala.Unit
Change the currently bound value, discarding the old value. Usually withValue() gives better semantics. |
|
def
withValue
[ S ]
( newval : T ) ( thunk : => S )
: S
Set the value of the fluid while executing the specified thunk. |
Constructor Detail |
def
this
( init : T )
Def Detail |
def
toString
: java.lang.String
def
value
: T
def
value_=
( newval : T ) : scala.Unit
def
withValue
[ S ]( newval : T ) ( thunk : => S ) : S