Safe Haskell | None |
---|---|
Language | GHC2021 |
Multitasking.Core
Synopsis
- multitask :: MonadIO m => (Coordinator -> IO a) -> m a
- data Coordinator
- start :: MonadIO m => Coordinator -> IO a -> m (Task a)
- newtype Task a = Task (Thread a)
- awaitTask :: MonadSTM m => Task a -> m a
- awaitAll :: MonadSTM m => Coordinator -> m ()
- startWith :: MonadIO m => Coordinator -> ThreadOptions -> IO a -> m (Task a)
- data ThreadOptions = ThreadOptions {}
- defaultThreadOptions :: ThreadOptions
- data ThreadAffinity
- = Unbound
- | Capability Int
- | OsThread
- data ByteCount
- kilobytes :: Natural -> ByteCount
- megabytes :: Natural -> ByteCount
Start tasks
multitask :: MonadIO m => (Coordinator -> IO a) -> m a Source #
Opens up a multitasking scope. No threads launched with the provided Coordinator
outlive this scope.
Before multitask
ends, it will cancel all threads. Use awaitAll
if you want to wait beforehand.
Additionally, exceptions between parent and children are propagated per default,
completely shutting down all processes when an exception happens anywhere.
data Coordinator Source #
Coordinator corresponds to the current multitasking scope.
Instances
Await Coordinator Source # | |||||
Defined in Multitasking.Core Associated Types
Methods await :: MonadSTM m => Coordinator -> m (Payload Coordinator) Source # probe :: MonadSTM m => Coordinator -> m (Maybe (Payload Coordinator)) Source # | |||||
type Payload Coordinator Source # | |||||
Defined in Multitasking.Core |
awaitAll :: MonadSTM m => Coordinator -> m () Source #
Control thread options
startWith :: MonadIO m => Coordinator -> ThreadOptions -> IO a -> m (Task a) Source #
Provice
data ThreadOptions #
affinity
The affinity of a thread. A thread can be unbound, bound to a specific capability, or bound to a specific OS thread.
Default:
Unbound
allocationLimit
The maximum number of bytes a thread may allocate before it is delivered an
AllocationLimitExceeded
exception. If caught, the thread is allowed to allocate an additional 100kb (tunable with+RTS -xq
) to perform any necessary cleanup actions; if exceeded, the thread is delivered another.Default:
Nothing
(no limit)label
The label of a thread, visible in the event log (
+RTS -l
).Default:
""
(no label)maskingState
The masking state a thread is created in. To unmask, use
unsafeUnmask
.Default:
Unmasked
Constructors
ThreadOptions | |
Fields |
Instances
Show ThreadOptions | |
Defined in Ki.Internal.ThreadOptions Methods showsPrec :: Int -> ThreadOptions -> ShowS # show :: ThreadOptions -> String # showList :: [ThreadOptions] -> ShowS # | |
Eq ThreadOptions | |
Defined in Ki.Internal.ThreadOptions Methods (==) :: ThreadOptions -> ThreadOptions -> Bool # (/=) :: ThreadOptions -> ThreadOptions -> Bool # |
defaultThreadOptions :: ThreadOptions #
Default thread options.
ThreadOptions
{affinity
=Unbound
,allocationLimit
= Nothing ,label
= "" ,maskingState
=Unmasked
}
data ThreadAffinity #
What, if anything, a thread is bound to.
Constructors
Unbound | Unbound. |
Capability Int | Bound to a capability. |
OsThread | Bound to an OS thread. |
Instances
Show ThreadAffinity | |
Defined in Ki.Internal.ThreadAffinity Methods showsPrec :: Int -> ThreadAffinity -> ShowS # show :: ThreadAffinity -> String # showList :: [ThreadAffinity] -> ShowS # | |
Eq ThreadAffinity | |
Defined in Ki.Internal.ThreadAffinity Methods (==) :: ThreadAffinity -> ThreadAffinity -> Bool # (/=) :: ThreadAffinity -> ThreadAffinity -> Bool # |
A number of bytes.
Instances
Show ByteCount | |
Eq ByteCount | |
Ord ByteCount | |