Hi All,

On 7/31/06, Einar Karttunen <ekarttun@cs.helsinki.fi> wrote:
My main objection to the TLS is that it looks like normal IO,
but changing the thread that evaluates it can break things in ways
that are hard to debug. E.g. we have an application that uses
TLS and passes an IO action to a library that happens to use
a pool of worker threads that invisible to the application.

This is why I believe transaction-local variables are a more useful concept.
You are garanteed that there is only one thread accessing them, and
they behave just like ordinary TVars except that each transaction has
its own copy.

I think you'd need an API like

   type LVar a -- "local" var
   newLVar :: a -> STM (LVar a)
   readLVar :: LVar a -> STM a
   writeLVar:: LVar a -> a -> STM ()

The argument to newLVar is an initial value that is used at the start
of each transaction.  Note that this means that the value in an LVar
does not persist between transaction. I agree that this limits their
use, but simplifies them immensely, and doesn't stand in the way their
being useful for solving a bunch of problems.

cheers,
Tom
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to