Optimizations for mutable structures?

John Meacham john at repetae.net
Wed Dec 7 19:24:19 EST 2005

On Thu, Dec 08, 2005 at 12:17:36AM -0000, Claus Reinke wrote:
> ps does your later email imply that you suggest IORef/MVar as
>     the non-volatile/volative separation? i'd rather see non-thread-
>     local IORefs phased out of ch..

yeah. exactly. thread local storage is also quite expensive though so
making all IORefs them would be a waste 90% of the time (as would making
them threadsafe).

I propose IORefs make no guarentees when it comes to concurrency, it is
the users burden to make sure they use them in a single threaded manner.

MVars should make guarentees when it comes to concurrency, and you
should use those whenever they might be accesed by different threads..

The reason all implementations should provide MVars (even if they are
just wrappers around IORefs) is so people can write portable threadsafe
libraries. mostly they can use IORefs, but should use MVars for things
like the unsafePerformIO global variable trick.

a thread-local version of MVars might also be interesting...


John Meacham - ⑆repetae.net⑆john⑈ 

More information about the Glasgow-haskell-users mailing list