+newUnique = atomically $ do
+ val <- readTVar uniqSource
+ let next = val+1
+ writeTVar uniqSource $! next
+ return (Unique next)
+
+-- SDM (18/3/2010): changed from MVar to STM. This fixes
+-- 1. there was no async exception protection
+-- 2. there was a space leak (now new value is strict)
+-- 3. using atomicModifyIORef would be slightly quicker, but can
+-- suffer from adverse scheduling issues (see #3838)
+-- 4. also, the STM version is faster.