Copyright | (c) 2016--2018 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | experimental |
Portability | ExistentialQuantification, RankNTypes |
Safe Haskell | None |
Language | Haskell2010 |
Operations and types for threads. This module is NOT considered to form part of the public interface of this library.
- type Threads n = Map ThreadId (Thread n)
- data Thread n = Thread {
- _continuation :: Action n
- _blocking :: Maybe BlockedOn
- _handlers :: [Handler n]
- _masking :: MaskingState
- _bound :: Maybe (BoundThread n)
- data BoundThread n = BoundThread {
- _runboundIO :: MVar n (n (Action n))
- _getboundIO :: MVar n (Action n)
- _boundTId :: ThreadId n
- mkthread :: Action n -> Thread n
- data BlockedOn
- (~=) :: Thread n -> BlockedOn -> Bool
- data Handler n = Exception e => Handler (e -> MaskingState -> Action n)
- propagate :: SomeException -> ThreadId -> Threads n -> Maybe (Threads n)
- interruptible :: Thread n -> Bool
- catching :: Exception e => (e -> Action n) -> ThreadId -> Threads n -> Threads n
- uncatching :: ThreadId -> Threads n -> Threads n
- except :: (MaskingState -> Action n) -> [Handler n] -> ThreadId -> Threads n -> Threads n
- mask :: MaskingState -> ThreadId -> Threads n -> Threads n
- goto :: Action n -> ThreadId -> Threads n -> Threads n
- launch :: ThreadId -> ThreadId -> ((forall b. ModelConc n b -> ModelConc n b) -> Action n) -> Threads n -> Threads n
- launch' :: MaskingState -> ThreadId -> ((forall b. ModelConc n b -> ModelConc n b) -> Action n) -> Threads n -> Threads n
- block :: BlockedOn -> ThreadId -> Threads n -> Threads n
- wake :: BlockedOn -> Threads n -> (Threads n, [ThreadId])
- makeBound :: MonadConc n => ThreadId -> Threads n -> n (Threads n)
- kill :: MonadConc n => ThreadId -> Threads n -> n (Threads n)
- runLiftedAct :: MonadConc n => ThreadId -> Threads n -> n (Action n) -> n (Action n)
Threads
All the state of a thread.
Thread | |
|
data BoundThread n Source #
The state of a bound thread.
BoundThread | |
|
Blocking
A BlockedOn
is used to determine what sort of variable a thread
is blocked on.
Exceptions
propagate :: SomeException -> ThreadId -> Threads n -> Maybe (Threads n) Source #
Propagate an exception upwards, finding the closest handler which can deal with it.
interruptible :: Thread n -> Bool Source #
Check if a thread can be interrupted by an exception.
catching :: Exception e => (e -> Action n) -> ThreadId -> Threads n -> Threads n Source #
Register a new exception handler.
except :: (MaskingState -> Action n) -> [Handler n] -> ThreadId -> Threads n -> Threads n Source #
Raise an exception in a thread.
mask :: MaskingState -> ThreadId -> Threads n -> Threads n Source #
Set the masking state of a thread.
Manipulating threads
launch :: ThreadId -> ThreadId -> ((forall b. ModelConc n b -> ModelConc n b) -> Action n) -> Threads n -> Threads n 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. ModelConc n b -> ModelConc n b) -> Action n) -> Threads n -> Threads n Source #
Start a thread with the given ID and masking state. This must not already be in use!
wake :: BlockedOn -> Threads n -> (Threads n, [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.
Bound threads
makeBound :: MonadConc n => ThreadId -> Threads n -> n (Threads n) Source #
Turn a thread into a bound thread.