[Haskell-cafe] Re: Stronger STM primitives needed? Or am I just doing it wrong?

Chris Smith cdsmith at twu.net
Tue Apr 22 20:48:17 EDT 2008


On Tue, 22 Apr 2008 14:48:54 -0700, Ryan Ingram wrote:
> waitFor t0 = do
>     t <- readTVar now
>     if (t < t0) then retry else return ()
> 
> This naive implementation has the problem that the transaction gets
> restarted every time "now" gets updated, even if the new value is still
> less than t0.
> 
> One primitive that would be strong enough is this: retryUntil :: TVar a
> -> (a -> Bool) -> STM ()

Hmm.  This makes me suspicious.  A change to a variable may change the 
transaction such that it never even calls your retryUntil the next time 
around.  Is it really safe to not retry the transaction?

-- 
Chris Smith



More information about the Haskell-Cafe mailing list