Copyright | (c) 2016--2017 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 r = Map ThreadId (Thread n r)
- data Thread n r = Thread {
- _continuation :: Action n r
- _blocking :: Maybe BlockedOn
- _handlers :: [Handler n r]
- _masking :: MaskingState
- _bound :: Maybe (BoundThread n r)
- data BoundThread n r = BoundThread {
- _runboundIO :: MVar n (n (Action n r))
- _getboundIO :: MVar n (Action n r)
- _boundTId :: ThreadId n
- mkthread :: Action n r -> Thread n r
- data BlockedOn
- (~=) :: Thread n r -> BlockedOn -> Bool
- data Handler n r = Exception e => Handler (e -> MaskingState -> Action n r)
- propagate :: SomeException -> ThreadId -> Threads n r -> Maybe (Threads n r)
- interruptible :: Thread n r -> Bool
- catching :: Exception e => (e -> Action n r) -> ThreadId -> Threads n r -> Threads n r
- uncatching :: ThreadId -> Threads n r -> Threads n r
- except :: (MaskingState -> Action n r) -> [Handler n r] -> ThreadId -> Threads n r -> Threads n r
- mask :: MaskingState -> ThreadId -> Threads n r -> Threads n r
- goto :: Action n r -> ThreadId -> Threads n r -> Threads n r
- launch :: ThreadId -> ThreadId -> ((forall b. M n r b -> M n r b) -> Action n r) -> Threads n r -> Threads n r
- launch' :: MaskingState -> ThreadId -> ((forall b. M n r b -> M n r b) -> Action n r) -> Threads n r -> Threads n r
- block :: BlockedOn -> ThreadId -> Threads n r -> Threads n r
- wake :: BlockedOn -> Threads n r -> (Threads n r, [ThreadId])
- makeBound :: MonadConc n => ThreadId -> Threads n r -> n (Threads n r)
- kill :: MonadConc n => ThreadId -> Threads n r -> n (Threads n r)
- runLiftedAct :: MonadConc n => ThreadId -> Threads n r -> n (Action n r) -> n (Action n r)
Threads
All the state of a thread.
Thread | |
|
data BoundThread n r 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
An exception handler.
Exception e => Handler (e -> MaskingState -> Action n r) |
propagate :: SomeException -> ThreadId -> Threads n r -> Maybe (Threads n r) Source #
Propagate an exception upwards, finding the closest handler which can deal with it.
interruptible :: Thread n r -> Bool Source #
Check if a thread can be interrupted by an exception.
catching :: Exception e => (e -> Action n r) -> ThreadId -> Threads n r -> Threads n r Source #
Register a new exception handler.
uncatching :: ThreadId -> Threads n r -> Threads n r Source #
Remove the most recent exception handler.
except :: (MaskingState -> Action n r) -> [Handler n r] -> ThreadId -> Threads n r -> Threads n r Source #
Raise an exception in a thread.
mask :: MaskingState -> ThreadId -> Threads n r -> Threads n r Source #
Set the masking state of a thread.
Manipulating threads
goto :: Action n r -> ThreadId -> Threads n r -> Threads n r Source #
Replace the Action
of a thread.
launch :: ThreadId -> ThreadId -> ((forall b. M n r b -> M n r b) -> Action n r) -> Threads n r -> Threads n r 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 b -> M n r b) -> Action n r) -> Threads n r -> Threads n r Source #
Start a thread with the given ID and masking state. This must not already be in use!
wake :: BlockedOn -> Threads n r -> (Threads n r, [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 r -> n (Threads n r) Source #
Turn a thread into a bound thread.