
23 Apr
2008
23 Apr
'08
12:13 p.m.
On Wed, Apr 23, 2008 at 7:54 AM, Tim Harris (RESEARCH)
What do you think about a slight change:
readTVarWhen :: TVar a -> (a -> bool) -> STM a
This seems strictly less powerful than retryUntil:
readTVarWhen v p = retryUntil v p >> readTVar v
Consider the following transaction:
intV :: TVar Int boolV :: TVar Bool
interesting = atomically $ do retryUntil intV (> 50) retryUntil boolV id
Lets say that intV contains 100 and boolV contains False. Then this transaction retries. Now, if intV changes to 101, this transaction doesn't need to re-run; we can see immediately that no predicate changed. Using "readTVarWhen", this is less clear; the transaction log would hold a read on intV which would be more difficult to ignore. -- ryan