[project @ 2002-04-24 16:31:37 by simonmar]
[ghc-base.git] / Control / Concurrent.hs
index 1409b75..6b3ec94 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- 
+-- |
 -- Module      :  Control.Concurrent
 -- Copyright   :  (c) The University of Glasgow 2001
 -- License     :  BSD-style (see the file libraries/core/LICENSE)
@@ -8,7 +8,7 @@
 -- Stability   :  experimental
 -- Portability :  non-portable
 --
--- $Id: Concurrent.hs,v 1.2 2001/08/07 15:25:04 simonmar Exp $
+-- $Id: Concurrent.hs,v 1.6 2002/04/24 16:31:37 simonmar Exp $
 --
 -- A common interface to a collection of useful concurrency
 -- abstractions.
@@ -53,8 +53,7 @@ import GHC.Conc
 import GHC.TopHandler   ( reportStackOverflow, reportError )
 import GHC.IOBase      ( IO(..) )
 import GHC.IOBase      ( unsafeInterleaveIO )
-import GHC.Base                ( fork# )
-import GHC.Prim                ( Addr#, unsafeCoerce# )
+import GHC.Base
 #endif
 
 #ifdef __HUGS__
@@ -76,7 +75,7 @@ import Control.Concurrent.SampleVar
 -- cmp_thread in the RTS.
 
 #ifdef __GLASGOW_HASKELL__
-foreign import ccall "cmp_thread" unsafe cmp_thread :: Addr# -> Addr# -> Int
+foreign import ccall unsafe "cmp_thread" cmp_thread :: Addr# -> Addr# -> Int
 -- Returns -1, 0, 1
 
 cmpThread :: ThreadId -> ThreadId -> Ordering
@@ -95,6 +94,13 @@ instance Eq ThreadId where
 instance Ord ThreadId where
    compare = cmpThread
 
+foreign import ccall unsafe "rts_getThreadId" getThreadId :: Addr# -> Int
+
+instance Show ThreadId where
+   showsPrec d (ThreadId t) = 
+       showString "ThreadId " . 
+        showsPrec d (getThreadId (unsafeCoerce# t))
+
 forkIO :: IO () -> IO ThreadId
 forkIO action = IO $ \ s -> 
    case (fork# action_plus s) of (# s1, id #) -> (# s1, ThreadId id #)