Class MonadAdvSTM

Takes a closure IO action and a commit IO action.
The commit IO action will be executed iff the transaction commits.
Commit actions are sequenced (within the same transaction), i.e.,

onCommitWith id (putStr "hello")
onCommitWith id (putStr " world")

will print "hello world".

The closure action is useful for encapsulating the commit actions,
e.g., within a database transaction.
The last call of onCommitWith in the transaction
is applied to the sequence of commit actions, i.e.:

When a TVar was modified in a transaction and the transaction tries to commit,
this update remains invisible to other threads until the corresponding
onCommit action is dispatched.

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
Deadlock exception to be thrown.

As a general rule, onCommit should
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:

Retries the transaction and uses unsafeIOToSTM to fork off a
thread that runs the given IO action. Since a transaction might be rerun
several times by the runtime system, it is your responsibility to
ensure that the IO-action is idempotent and releases all acquired locks.

Reads a value from a TVar. Blocks until the IO onCommit aidction(s) of
the corresponding transaction are complete.is not the last function
See onCommit for a more detailed description of this behaviour.