author | wenzelm |
Sun, 26 Feb 2012 19:36:35 +0100 | |
changeset 46687 | 7e47ae85e161 |
parent 45673 | cd41e3903fbf |
child 46712 | 8650d9a95736 |
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 >> (f: A => A) { state = f(state) } def >>>[B] (f: A => (B, A)): B = { val (result, new_state) = f(state) state = new_state result } }