Asynchronous exceptions and laziness bugs in
Bas van Dijk
v.dijk.bas at gmail.com
Fri Mar 19 09:16:19 EDT 2010
On Thu, Mar 18, 2010 at 11:45 AM, Simon Marlow <marlowsd at gmail.com> wrote:
> Thanks, I'm actually going to change this to use STM as it does a better job
> than MVars in this case.
Hi Simon, I see you actually write 'val+1' to the MVar:
newUnique :: IO Unique
newUnique = atomically $ do
val <- readTVar uniqSource
let next = val+1
writeTVar uniqSource $! val + 1
return (Unique next)
Why don't you write 'next' so that when you force the returned Unique
it doesn't need to be computed a second time?
(The attached patch fixes it)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 27970 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/libraries/attachments/20100319/586b199b/write-next-0001.obj
More information about the Libraries