Optimizations for mutable structures?

John Meacham john at repetae.net
Wed Dec 7 18:41:32 EST 2005

On Wed, Dec 07, 2005 at 05:36:09PM +0000, Malcolm Wallace wrote:
> My expectation is that the config data /will/ have been changed by
> some other GUI thread.  Surely it cannot be OK for the compiler to
> silently deliver the original unchanged data here - it goes against
> the programmer's intention.

then you should be using MVars. I don't think ghc guarentees (except by
accident of implementation) anything about using IORefs from multiple
threads and you shouldn't count on code which does so working in the
future. At least it shouldn't, since thread synchronization is a very
expensive thing compared to direct memory access and registers.

this is something of an argument for providing MVars or some thread-safe
version of IORefs with all haskell implementations whether they have
concurrency or not so people can write portable thread-safe libraries
that don't actually use concurrency themselves.


John Meacham - ⑆repetae.net⑆john⑈ 

More information about the Glasgow-haskell-users mailing list