Copyright | (c) 2016 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
- mkthread :: Action n r -> Thread n r
- data BlockedOn
- (~=) :: Thread n r -> BlockedOn -> Bool
- data Handler n r = Exception e => Handler (e -> 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 :: 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
- kill :: ThreadId -> Threads n r -> Threads n r
- block :: BlockedOn -> ThreadId -> Threads n r -> Threads n r
- wake :: BlockedOn -> Threads n r -> (Threads n r, [ThreadId])
Threads
All the state of a thread.
Thread | |
|
Blocking
A BlockedOn
is used to determine what sort of variable a thread
is blocked on.
Exceptions
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 :: 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!