Safe Haskell | None |
---|---|
Language | Haskell2010 |
Operations and types for threads.
- type Threads n r s = Map ThreadId (Thread n r s)
- data Thread n r s = Thread {
- _continuation :: Action n r s
- _blocking :: Maybe BlockedOn
- _handlers :: [Handler n r s]
- _masking :: MaskingState
- _known :: [Either MVarId TVarId]
- _fullknown :: Bool
- mkthread :: Action n r s -> Thread n r s
- data BlockedOn
- (~=) :: Thread n r s -> BlockedOn -> Bool
- isLocked :: ThreadId -> Threads n r a -> Bool
- data Handler n r s = forall e . Exception e => Handler (e -> Action n r s)
- propagate :: SomeException -> ThreadId -> Threads n r s -> Maybe (Threads n r s)
- interruptible :: Thread n r s -> Bool
- catching :: Exception e => (e -> Action n r s) -> ThreadId -> Threads n r s -> Threads n r s
- uncatching :: ThreadId -> Threads n r s -> Threads n r s
- except :: Action n r s -> [Handler n r s] -> ThreadId -> Threads n r s -> Threads n r s
- mask :: MaskingState -> ThreadId -> Threads n r s -> Threads n r s
- goto :: Action n r s -> ThreadId -> Threads n r s -> Threads n r s
- launch :: ThreadId -> ThreadId -> ((forall b. M n r s b -> M n r s b) -> Action n r s) -> Threads n r s -> Threads n r s
- launch' :: MaskingState -> ThreadId -> ((forall b. M n r s b -> M n r s b) -> Action n r s) -> Threads n r s -> Threads n r s
- kill :: ThreadId -> Threads n r s -> Threads n r s
- block :: BlockedOn -> ThreadId -> Threads n r s -> Threads n r s
- wake :: BlockedOn -> Threads n r s -> (Threads n r s, [ThreadId])
- knows :: [Either MVarId TVarId] -> ThreadId -> Threads n r s -> Threads n r s
- forgets :: [Either MVarId TVarId] -> ThreadId -> Threads n r s -> Threads n r s
- fullknown :: ThreadId -> Threads n r s -> Threads n r s
Threads
type Threads n r s = Map ThreadId (Thread n r s) Source
Threads are stored in a map index by ThreadId
.
All the state of a thread.
Thread | |
|
Blocking
A BlockedOn
is used to determine what sort of variable a thread
is blocked on.
isLocked :: ThreadId -> Threads n r a -> Bool Source
Determine if a thread is deadlocked. If at least one thread is not in a fully-known state, this will only check for global deadlock.
Exceptions
propagate :: SomeException -> ThreadId -> Threads n r s -> Maybe (Threads n r s) Source
Propagate an exception upwards, finding the closest handler which can deal with it.
interruptible :: Thread n r s -> Bool Source
Check if a thread can be interrupted by an exception.
catching :: Exception e => (e -> Action n r s) -> ThreadId -> Threads n r s -> Threads n r s Source
Register a new exception handler.
uncatching :: ThreadId -> Threads n r s -> Threads n r s Source
Remove the most recent exception handler.
except :: Action n r s -> [Handler n r s] -> ThreadId -> Threads n r s -> Threads n r s Source
Raise an exception in a thread.
mask :: MaskingState -> ThreadId -> Threads n r s -> Threads n r s Source
Set the masking state of a thread.
Manipulating threads
goto :: Action n r s -> ThreadId -> Threads n r s -> Threads n r s Source
Replace the Action
of a thread.
launch :: ThreadId -> ThreadId -> ((forall b. M n r s b -> M n r s b) -> Action n r s) -> Threads n r s -> Threads n r s Source
Start a thread with the given ID, inheriting the masking state from the parent thread. This ID must not already be in use!
launch' :: MaskingState -> ThreadId -> ((forall b. M n r s b -> M n r s b) -> Action n r s) -> Threads n r s -> Threads n r s Source
Start a thread with the given ID and masking state. This must not already be in use!
wake :: BlockedOn -> Threads n r s -> (Threads n r s, [ThreadId]) Source
Unblock all threads waiting on the appropriate block. For TVar
blocks, this will wake all threads waiting on at least one of the
given TVar
s.
knows :: [Either MVarId TVarId] -> ThreadId -> Threads n r s -> Threads n r s Source
Record that a thread knows about a shared variable.