Skip to content

Commit

Permalink
Write-only transactions can be assumed valid
Browse files Browse the repository at this point in the history
  • Loading branch information
djspiewak committed Nov 23, 2008
1 parent 3b6eea3 commit b659c9b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/scala/com/codecommit/stm/Transaction.scala
Expand Up @@ -57,9 +57,13 @@ final class Transaction private[stm] (val rev: Int) extends Context {
writes foreach { _.lock() }
try {
val f = { ref: Ref[Any] => ref.rev == version(ref) }
val back = if (writes.size != 0) { // allow snapshot read-points

// read or write-only transactions should not retry
val back = if ((writes.size | reads.size) == 0) {
true
} else {
reads.forall(f) && writes.forall(f)
} else true
}

if (back) {
for (ref <- writes) {
Expand Down

0 comments on commit b659c9b

Please sign in to comment.