[project @ 2002-04-24 16:31:37 by simonmar]
[ghc-base.git] / Control / Concurrent.hs
index f3a426e..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.4 2002/04/10 15:57:16 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.
@@ -94,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 #)