src/Pure/Concurrent/counter.scala
author bulwahn
Sat, 09 Jul 2011 19:28:33 +0200
changeset 43733 a6ca7b83612f
parent 43660 bfc0bb115fa1
child 45243 27466646a7a3
permissions -rw-r--r--
adding code equations to execute floor and ceiling on rational and real numbers

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

Synchronized counter for unique identifiers < 0.

NB: ML ticks forwards, JVM ticks backwards.
*/

package isabelle


object Counter
{
  type ID = Long
}

class Counter
{
  private var count: Counter.ID = 0

  def apply(): Counter.ID = synchronized {
    require(count > java.lang.Long.MIN_VALUE)
    count -= 1
    count
  }
}