[project @ 2002-10-18 16:29:18 by malcolm]
authormalcolm <unknown>
Fri, 18 Oct 2002 16:29:18 +0000 (16:29 +0000)
committermalcolm <unknown>
Fri, 18 Oct 2002 16:29:18 +0000 (16:29 +0000)
Implement atomicModifyIORef for nhc98.

Data/IORef.hs

index af8ebda..9170faf 100644 (file)
@@ -48,6 +48,7 @@ import NHC.IOExtras
     , newIORef
     , readIORef
     , writeIORef
+    , excludeFinalisers
     )
 #endif
 
@@ -86,4 +87,11 @@ atomicModifyIORef = plainModifyIORef -- Hugs has no preemption
   where plainModifyIORef r f = do
                a <- readIORef r
                case f a of (a',b) -> writeIORef r a' >> return b
+#elif defined(__NHC__)
+atomicModifyIORef r f =
+  excludeFinalisers $ do
+    a <- readIORef r
+    let (a',b) = f a
+    writeIORef r a'
+    return b
 #endif