summaryrefslogtreecommitdiff
path: root/libraries/base/Data/Unique.hs
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2013-06-08 17:06:13 +0100
committerIan Lynagh <ian@well-typed.com>2013-06-08 17:06:13 +0100
commit68288cf9a963fff60beb4d86a2360fda44ba6890 (patch)
tree35723f55f145d7c89d7e2fc5597e0d887012d131 /libraries/base/Data/Unique.hs
parent374fcdd083a85ae6b2ece537e8a01cf10abc763d (diff)
downloadhaskell-68288cf9a963fff60beb4d86a2360fda44ba6890.tar.gz
Change a use of atomicModifyIORef to atomicModifyIORef'
Resulting core is unchanged.
Diffstat (limited to 'libraries/base/Data/Unique.hs')
-rw-r--r--libraries/base/Data/Unique.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/libraries/base/Data/Unique.hs b/libraries/base/Data/Unique.hs
index b8aa6cd63a..ffd45f9427 100644
--- a/libraries/base/Data/Unique.hs
+++ b/libraries/base/Data/Unique.hs
@@ -55,8 +55,8 @@ uniqSource = unsafePerformIO (newIORef 0)
-- times 'newUnique' may be called.
newUnique :: IO Unique
newUnique = do
- r <- atomicModifyIORef uniqSource $ \x -> let z = x+1 in (z,z)
- r `seq` return (Unique r)
+ r <- atomicModifyIORef' uniqSource $ \x -> let z = x+1 in (z,z)
+ return (Unique r)
-- SDM (18/3/2010): changed from MVar to STM. This fixes
-- 1. there was no async exception protection
@@ -73,6 +73,10 @@ newUnique = do
-- Unique.
-- 3. IORef version is very slightly faster.
+-- IGL (08/06/2013): changed to using atomicModifyIORef' instead.
+-- This feels a little safer, from the point of view of not leaking
+-- memory, but the resulting core is identical.
+
-- | Hashes a 'Unique' into an 'Int'. Two 'Unique's may hash to the
-- same value, although in practice this is unlikely. The 'Int'
-- returned makes a good hash key.