|Portability||non-portable (requires STM)|
|Maintainer||Peter Robinson <email@example.com>|
Provides the type class MonadAdvSTM and the AdvSTM monad. Parts of this implementation were taken from the HaskellWiki Page of MonadAdvSTM (see package description).
- class Monad m => MonadAdvSTM m where
- data AdvSTM a
A type class for extended-STM monads. For a concrete instantiation see
Takes an IO action that will be executed iff the transaction commits.
- When a TVar was modified in a transaction and this transaction commits, this update remains invisible to other threads until the corresponding onCommit action was run.
- If the onCommit action throws an exception, the original value of the TVars will be restored.
- Accessing a modified TVar within the onCommit action will cause a
Deadlockexception to be thrown.
As a general rule,
only be used for "real" (i.e. without atomic blocks) IO actions and is certainly
not the right place to fiddle with TVars. For example, if you wanted to
write a TVar value to a file on commit, you could write:
tvar <- newTVarIO "bla" atomically $ do x <- readTVar tvar onCommit (writeFile "myfile" x)
Adds an IO action to the retry job-queue. If the transaction retries, a new helper thread is forked that runs the retry actions, and, after the helper thread is done, the transaction retries. Warning: Uses unsafeIOToSTM to fork a helper thread that runs the retry actions!
retry. Skips any IO actions added by unsafeOnRetry.
Runs a transaction atomically in the
Lifts STM actions to