diff options
author | Hubert Plociniczak <hubert.plociniczak@epfl.ch> | 2011-11-02 14:34:35 +0000 |
---|---|---|
committer | Hubert Plociniczak <hubert.plociniczak@epfl.ch> | 2011-11-02 14:34:35 +0000 |
commit | b6778be91900b8161e705dc2598ef7af86842b0b (patch) | |
tree | d15e8ec18a37eec212f50f1ace27714d7e7d4d34 /test/files/pos/Transactions.scala | |
parent | ac6c76f26d884a94d0c9ff54f055d3f9ab750bac (diff) | |
download | scala-b6778be91900b8161e705dc2598ef7af86842b0b.tar.gz scala-b6778be91900b8161e705dc2598ef7af86842b0b.tar.bz2 scala-b6778be91900b8161e705dc2598ef7af86842b0b.zip |
Begone t1737...
Diffstat (limited to 'test/files/pos/Transactions.scala')
-rw-r--r-- | test/files/pos/Transactions.scala | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/files/pos/Transactions.scala b/test/files/pos/Transactions.scala index ed989e178e..9b4388300b 100644 --- a/test/files/pos/Transactions.scala +++ b/test/files/pos/Transactions.scala @@ -28,7 +28,7 @@ class Transaction { var next: Transaction = null def this(hd: Transaction, tl: Transaction) = { this(); this.head = head; this.next = next } - + def makeAbort() = synchronized { while (status != Transaction.Aborted && status != Transaction.Committed) { status = Transaction.Abortable @@ -48,7 +48,7 @@ class Transaction { case ex: AbortException => abort(); None case ex: Throwable => abort(); throw ex } - + } trait Transactional { @@ -58,7 +58,7 @@ trait Transactional { /** copy back snapshot */ def rollBack(): Unit - + var readers: Transaction var writer: Transaction @@ -66,11 +66,11 @@ trait Transactional { if (writer == null) null else if (writer.status == Transaction.Running) writer else { - if (writer.status != Transaction.Committed) rollBack(); - writer = null; - null + if (writer.status != Transaction.Committed) rollBack(); + writer = null; + null } - + def getter(thisTrans: Transaction) { if (writer == thisTrans) return var r = readers @@ -96,7 +96,7 @@ trait Transactional { synchronized { val w = currentWriter() if (w != null) - if (thisTrans.id < w.id) { w.makeAbort(); rollBack() } + if (thisTrans.id < w.id) { w.makeAbort(); rollBack() } else throw new AbortException var r = readers while (r != null && r.head.status != Transaction.Running) { r = r.next; readers = r } @@ -111,4 +111,4 @@ trait Transactional { } } } - + |