This commentary page describes a lot of the fine details of STM
in GHC, but I'd like clarity on a couple points.
First, is a nested transaction invalidated when variables accessed in the parent change?
For instance we have in thread A
:
takeTMVar a `orElse` takeTMVar b `orElse` takeTMVar c
Say that while A
is executing the nested transaction takeTMVar b
, another thread B
does a putTMVar a ()
; can thread A
successfully complete its nested transaction, or is it invalidated (this would strike me as wrong)?
A second point which I think I understand but wouldn't mind reassurance on: in the case where the entire top-level transaction described above for A
is retried and finally blocks, is it correct that A
will be awoken when any of a
, b
, or c
change?
Finally as a bonus, do the semantics of the transaction above change if we (or library authors) change orElse
to infixr
?