blob: dbb2eda5ad592756ee569f1372598d45cbf23807 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
{-# LANGUAGE MagicHash, NoImplicitPrelude #-}
{-# OPTIONS_HADDOCK not-home #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.Conc.Sync [boot]
-- Copyright : (c) The University of Glasgow, 1994-2002
-- License : see libraries/base/LICENSE
--
-- Maintainer : cvs-ghc@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC extensions)
--
-- Basic concurrency stuff.
--
-----------------------------------------------------------------------------
module GHC.Conc.Sync
( forkIO,
TVar(..),
ThreadId(..),
myThreadId,
showThreadId,
ThreadStatus(..),
threadStatus,
sharedCAF,
labelThreadByteArray#
) where
import GHC.Base
import GHC.Ptr
forkIO :: IO () -> IO ThreadId
data ThreadId = ThreadId ThreadId#
data TVar a = TVar (TVar# RealWorld a)
data BlockReason
= BlockedOnMVar
-- ^blocked on 'MVar'
{- possibly (see 'threadstatus' below):
| BlockedOnMVarRead
-- ^blocked on reading an empty 'MVar'
-}
| BlockedOnBlackHole
-- ^blocked on a computation in progress by another thread
| BlockedOnException
-- ^blocked in 'throwTo'
| BlockedOnSTM
-- ^blocked in 'retry' in an STM transaction
| BlockedOnForeignCall
-- ^currently in a foreign call
| BlockedOnOther
-- ^blocked on some other resource. Without @-threaded@,
-- I\/O and 'threadDelay' show up as 'BlockedOnOther', with @-threaded@
-- they show up as 'BlockedOnMVar'.
data ThreadStatus
= ThreadRunning
-- ^the thread is currently runnable or running
| ThreadFinished
-- ^the thread has finished
| ThreadBlocked BlockReason
-- ^the thread is blocked on some resource
| ThreadDied
-- ^the thread received an uncaught exception
myThreadId :: IO ThreadId
showThreadId :: ThreadId -> String
threadStatus :: ThreadId -> IO ThreadStatus
sharedCAF :: a -> (Ptr a -> IO (Ptr a)) -> IO a
labelThreadByteArray# :: ThreadId -> ByteArray# -> IO ()
|