From c74c72f60dcc4cbea519826e98ec90ad8016b49d Mon Sep 17 00:00:00 2001 From: Thomas Schilling Date: Sat, 22 Aug 2009 23:09:37 +0000 Subject: [PATCH] Make consIORef atomic. --- compiler/utils/Util.lhs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index 37aedc8..d8b61f8 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} -- 1.7.10.4