src/Pure/Concurrent/volatile.scala
author blanchet
Mon, 27 Jun 2011 14:56:33 +0200
changeset 43576 ebeda6275027
parent 38840 ec75dc58688b
child 43719 ba1b2c918c32
permissions -rw-r--r--
don't export any metastrange or other nonatomizable formulas, since these don't help proving normal things, they are somewhat broken in the ATP output, and they are atypical

/*  Title:      Pure/Concurrent/volatile.scala
    Author:     Makarius

Volatile variables.
*/

package isabelle


class Volatile[A](init: A)
{
  @volatile private var state: A = init
  def peek(): 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
  }
}