
19 Mar
2010
19 Mar
'10
9:53 a.m.
On 19/03/2010 13:16, Bas van Dijk wrote:
On Thu, Mar 18, 2010 at 11:45 AM, Simon Marlow
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)
Yes, silly mistake. I'll apply your patch, thanks. Cheers, Simon