src/Pure/Concurrent/volatile.scala
changeset 46712 8650d9a95736
parent 46687 7e47ae85e161
child 56685 535d59d4ed12
equal deleted inserted replaced
46711:f745bcc4a1e5 46712:8650d9a95736
    12 {
    12 {
    13   def apply[A](init: A): Volatile[A] = new Volatile(init)
    13   def apply[A](init: A): Volatile[A] = new Volatile(init)
    14 }
    14 }
    15 
    15 
    16 
    16 
    17 class Volatile[A] private(init: A)
    17 final class Volatile[A] private(init: A)
    18 {
    18 {
    19   @volatile private var state: A = init
    19   @volatile private var state: A = init
    20   def apply(): A = state
    20   def apply(): A = state
    21   def >> (f: A => A) { state = f(state) }
    21   def >> (f: A => A) { state = f(state) }
    22   def >>>[B] (f: A => (B, A)): B =
    22   def >>>[B] (f: A => (B, A)): B =