summaryrefslogtreecommitdiff
path: root/compiler/utils/Util.lhs
diff options
context:
space:
mode:
authorThomas Schilling <nominolo@googlemail.com>2009-08-22 23:09:37 +0000
committerThomas Schilling <nominolo@googlemail.com>2009-08-22 23:09:37 +0000
commitc74c72f60dcc4cbea519826e98ec90ad8016b49d (patch)
tree3e788a7fb1367b8889a67db28b3f6b70e8cf19c0 /compiler/utils/Util.lhs
parent4201e0f80cf3b47093b60c47d7bf733f17912d81 (diff)
downloadhaskell-c74c72f60dcc4cbea519826e98ec90ad8016b49d.tar.gz
Make consIORef atomic.
Diffstat (limited to 'compiler/utils/Util.lhs')
-rw-r--r--compiler/utils/Util.lhs6
1 files changed, 2 insertions, 4 deletions
diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs
index 37aedc8df4..d8b61f898d 100644
--- a/compiler/utils/Util.lhs
+++ b/compiler/utils/Util.lhs
@@ -79,9 +79,8 @@ module Util (
import Panic
-import Data.IORef ( IORef, newIORef )
+import Data.IORef ( IORef, newIORef, atomicModifyIORef )
import System.IO.Unsafe ( unsafePerformIO )
-import Data.IORef ( readIORef, writeIORef )
import Data.List hiding (group)
import Control.Concurrent.MVar ( MVar, newMVar, newEmptyMVar )
@@ -696,8 +695,7 @@ global a = unsafePerformIO (newIORef a)
\begin{code}
consIORef :: IORef [a] -> a -> IO ()
consIORef var x = do
- xs <- readIORef var
- writeIORef var (x:xs)
+ atomicModifyIORef var (\xs -> (x:xs,()))
\end{code}
\begin{code}