47b6ef647846ed689d4800bc801387f0ed821751
[ghc-base.git] / GHC / Conc.lhs
1 \begin{code}
2 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
3 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
4 {-# OPTIONS_HADDOCK not-home #-}
5 -----------------------------------------------------------------------------
6 -- |
7 -- Module      :  GHC.Conc
8 -- Copyright   :  (c) The University of Glasgow, 1994-2002
9 -- License     :  see libraries/base/LICENSE
10 -- 
11 -- Maintainer  :  cvs-ghc@haskell.org
12 -- Stability   :  internal
13 -- Portability :  non-portable (GHC extensions)
14 --
15 -- Basic concurrency stuff.
16 -- 
17 -----------------------------------------------------------------------------
18
19 -- No: #hide, because bits of this module are exposed by the stm package.
20 -- However, we don't want this module to be the home location for the
21 -- bits it exports, we'd rather have Control.Concurrent and the other
22 -- higher level modules be the home.  Hence:
23
24 #include "Typeable.h"
25
26 -- #not-home
27 module GHC.Conc
28         ( ThreadId(..)
29
30         -- * Forking and suchlike
31         , forkIO        -- :: IO a -> IO ThreadId
32         , forkIOUnmasked
33         , forkOnIO      -- :: Int -> IO a -> IO ThreadId
34         , forkOnIOUnmasked
35         , numCapabilities -- :: Int
36         , numSparks       -- :: IO Int
37         , childHandler  -- :: Exception -> IO ()
38         , myThreadId    -- :: IO ThreadId
39         , killThread    -- :: ThreadId -> IO ()
40         , throwTo       -- :: ThreadId -> Exception -> IO ()
41         , par           -- :: a -> b -> b
42         , pseq          -- :: a -> b -> b
43         , runSparks
44         , yield         -- :: IO ()
45         , labelThread   -- :: ThreadId -> String -> IO ()
46
47         , ThreadStatus(..), BlockReason(..)
48         , threadStatus  -- :: ThreadId -> IO ThreadStatus
49
50         -- * Waiting
51         , threadDelay           -- :: Int -> IO ()
52         , registerDelay         -- :: Int -> IO (TVar Bool)
53         , threadWaitRead        -- :: Int -> IO ()
54         , threadWaitWrite       -- :: Int -> IO ()
55
56         -- * TVars
57         , STM(..)
58         , atomically    -- :: STM a -> IO a
59         , retry         -- :: STM a
60         , orElse        -- :: STM a -> STM a -> STM a
61         , throwSTM      -- :: Exception e => e -> STM a
62         , catchSTM      -- :: Exception e => STM a -> (e -> STM a) -> STM a
63         , alwaysSucceeds -- :: STM a -> STM ()
64         , always        -- :: STM Bool -> STM ()
65         , TVar(..)
66         , newTVar       -- :: a -> STM (TVar a)
67         , newTVarIO     -- :: a -> STM (TVar a)
68         , readTVar      -- :: TVar a -> STM a
69         , readTVarIO    -- :: TVar a -> IO a
70         , writeTVar     -- :: a -> TVar a -> STM ()
71         , unsafeIOToSTM -- :: IO a -> STM a
72
73         -- * Miscellaneous
74         , withMVar
75 #ifdef mingw32_HOST_OS
76         , asyncRead     -- :: Int -> Int -> Int -> Ptr a -> IO (Int, Int)
77         , asyncWrite    -- :: Int -> Int -> Int -> Ptr a -> IO (Int, Int)
78         , asyncDoProc   -- :: FunPtr (Ptr a -> IO Int) -> Ptr a -> IO Int
79
80         , asyncReadBA   -- :: Int -> Int -> Int -> Int -> MutableByteArray# RealWorld -> IO (Int, Int)
81         , asyncWriteBA  -- :: Int -> Int -> Int -> Int -> MutableByteArray# RealWorld -> IO (Int, Int)
82 #endif
83
84 #ifndef mingw32_HOST_OS
85         , Signal, HandlerFun, setHandler, runHandlers
86 #endif
87
88         , ensureIOManagerIsRunning
89
90 #ifdef mingw32_HOST_OS
91         , ConsoleEvent(..)
92         , win32ConsoleHandler
93         , toWin32ConsoleEvent
94 #endif
95         , setUncaughtExceptionHandler      -- :: (Exception -> IO ()) -> IO ()
96         , getUncaughtExceptionHandler      -- :: IO (Exception -> IO ())
97
98         , reportError, reportStackOverflow
99         ) where
100
101 import GHC.Conc.IO
102 import GHC.Conc.Sync
103
104 #ifndef mingw32_HOST_OS
105 import GHC.Conc.Signal
106 #endif
107
108 \end{code}