> > The problem was whether DiffArrays should be thread-safe in the > > Concurrent Haskell sense, which means protecting access to > the DiffArray > > with an MVar. > > Can you give some estimate of the cost of using an MVar in this way?
It depends a lot on whether the cost of using the MVar is dwarfed by other costs in the relevant operations. For example, Handles are protected by MVars but this isn't a big deal because you don't usually do lots of tiny operations on a Handle (well, it bites you if you try to implement 'cat' using hGetChar/hPutChar). Compared to an IORef, modifying an MVar is many times more expensive. takeMVar/putMVar are implemented as out-of-line calls, but they could be partially inlined to cover the cases where they don't need to block if efficiency is really critical. > Could some cheaper mechanism be provided for the special case > of a mutex? My guess is that it wouldn't be worth having a special mutex type instead of (MVar ()). Cheers, Simon _______________________________________________ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users