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

Ryan Ingram ryani.spam at gmail.com
Tue Apr 22 21:14:25 EDT 2008


On 4/22/08, Chris Smith <cdsmith at twu.net> wrote:
> > 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?

Of course not; the semantics would be that the transaction log,
instead of saying "I read from v" would say "I read from v and failed
because v didn't satisfy this predicate".

Changes to any other variable in the log would have the same effect as
always: restarting the transaction.  This is actually required in my
desired use case; I want to block until "now" becomes >= t, or a
different TVar gets filled with a non-Nothing value.

  -- ryan


More information about the Haskell-Cafe mailing list