| author | wenzelm | 
| Sun, 26 Feb 2012 18:25:28 +0100 | |
| changeset 46684 | 7f741b2c82a3 | 
| parent 45673 | cd41e3903fbf | 
| child 46687 | 7e47ae85e161 | 
| permissions | -rw-r--r-- | 
/* Title: Pure/Concurrent/volatile.scala Module: PIDE Author: Makarius Volatile variables. */ package isabelle object Volatile { def apply[A](init: A): Volatile[A] = new Volatile(init) } class Volatile[A] private(init: A) { @volatile private var state: A = init def apply(): A = state def change(f: A => A) { state = f(state) } def change_yield[B](f: A => (B, A)): B = { val (result, new_state) = f(state) state = new_state result } }