important news: refocusing discussion

Ross Paterson ross at soi.city.ac.uk
Mon Mar 27 18:24:09 EST 2006


On Mon, Mar 27, 2006 at 09:36:28AM +0100, Simon Marlow wrote:
> On 26 March 2006 03:44, Ross Paterson wrote:
> > [...] the key point is that
> > a Haskell' module that does not use concurrency, but is thread-safe,
> > ought to work with non-concurrent implementations too.
> > 
> > To make that work, we'd need two interfaces:
> >  * one for applications that make use of concurrency.  This would be
> >    unavailable on some implementations.
> >  * one for thread-safe use of state.  This would be available on all
> >    implementations, and authors not requiring concurrency would be
> >    encouraged to use it for maximum portability.
> 
> Sure, I think this is a point on which we're all agreed.
> 
> The portable interface could be Control.Concurrent.MVar, perhaps.

As Malcolm pointed out, using MVars requires some care, even if you were
just aiming to be thread-safe.  Packaged things like atomicModifyIORef
are safe, but awkward, and need extra stuff to handle multiple variables.

How about STM (minus retry/orElse) and TVars as the portable interface?
They're trivial for a single-threaded implementation, and provide a
comfortable interface for everyone.



More information about the Haskell-prime mailing list