aboutsummaryrefslogtreecommitdiff
path: root/tests/bench/transactional/Transaction.scala
blob: dbb28d4527a5f3d88c5343b882e64ead2bfdebe5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package transactional
import collection.mutable.ListBuffer

class Transaction {
  private val log = new ListBuffer[String]
  def println(s: String): Unit = log += s

  private var aborted = false
  private var committed = false

  def abort(): Unit = { aborted = true }
  def isAborted = aborted

  def commit(): Unit =
    if (!aborted && !committed) {
      //Console.println("******* log ********")
      //log.foreach(Console.println)
      committed = true
    }
}