X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fghc%2FIOHandle.lhs;h=a2787815a919f98aa9247fa9ec1476489d0d24d5;hb=9dd6e1c216993624a2cd74b62ca0f0569c02c26b;hp=b0c3c81dbc4f6d438c90096a5f24c9ecd1017269;hpb=ff14742cc328f19b9bf7c04d9a69408e641cf64a;p=ghc-hetmet.git diff --git a/ghc/lib/ghc/IOHandle.lhs b/ghc/lib/ghc/IOHandle.lhs index b0c3c81..a278781 100644 --- a/ghc/lib/ghc/IOHandle.lhs +++ b/ghc/lib/ghc/IOHandle.lhs @@ -58,15 +58,24 @@ readHandle :: Handle -> IO Handle__ writeHandle :: Handle -> Handle__ -> IO () #if defined(__CONCURRENT_HASKELL__) -newHandle = newMVar -readHandle = takeMVar -writeHandle = putMVar + +-- Use MVars for concurrent Haskell +newHandle hc = newMVar hc >>= \ h -> + return (Handle h) + +readHandle (Handle h) = takeMVar h +writeHandle (Handle h) hc = putMVar h hc + #else -newHandle v = stToIO (newVar v) -readHandle h = stToIO (readVar h) -writeHandle h v = stToIO (writeVar h v) -#endif +-- Use ordinary MutableVars for non-concurrent Haskell +newHandle hc = stToIO (newVar hc >>= \ h -> + return (Handle h)) + +readHandle (Handle h) = stToIO (readVar h) +writeHandle (Handle h) hc = stToIO (writeVar h hc) + +#endif \end{code} %********************************************************* @@ -885,5 +894,4 @@ access of a closed file. ioe_closedHandle :: Handle -> IO a ioe_closedHandle h = fail (IOError (Just h) IllegalOperation "handle is closed") - \end{code}