aboutsummaryrefslogtreecommitdiff
path: root/stm.go
diff options
context:
space:
mode:
Diffstat (limited to 'stm.go')
-rw-r--r--stm.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/stm.go b/stm.go
index aa65747..148a404 100644
--- a/stm.go
+++ b/stm.go
@@ -61,11 +61,12 @@ y, and block if both values are zero.
// returns a transaction function.
stm.Atomically(stm.Select(dec(x), dec(y)))
-An important caveat: transactions must not have side effects! This is because a
-transaction may be restarted several times before completing, meaning the side
-effects may execute more than once. This will almost certainly cause incorrect
-behavior. One common way to get around this is to build up a list of operations
-to perform inside the transaction, and then perform them after the transaction
+An important caveat: transactions must be idempotent (they should have the
+same effect every time they are invoked). This is because a transaction may be
+retried several times before successfully completing, meaning its side effects
+may execute more than once. This will almost certainly cause incorrect
+behavior. One common way to get around this is to build up a list of impure
+operations inside the transaction, and then perform them after the transaction
completes.
The stm API tries to mimic that of Haskell's Control.Concurrent.STM, but this