| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Ki.Unlifted
Description
The ki API, generalized to use MonadUnliftIO.
Note: See Ki for the main module documentation. Any
documentation you see here is incidental, and only a result of re-exporting symbols directly from
Ki.
Synopsis
- data Scope
- data Thread a
- scoped :: forall a m. MonadUnliftIO m => (Scope -> m a) -> m a
- fork :: forall a m. MonadUnliftIO m => Scope -> m a -> m (Thread a)
- forkTry :: (Exception e, MonadUnliftIO m) => Scope -> m a -> m (Thread (Either e a))
- await :: Thread a -> STM a
- awaitAll :: Scope -> STM ()
- fork_ :: MonadUnliftIO m => Scope -> m Void -> m ()
- forkWith :: forall a m. MonadUnliftIO m => Scope -> ThreadOptions -> m a -> m (Thread a)
- forkWith_ :: MonadUnliftIO m => Scope -> ThreadOptions -> m Void -> m ()
- forkTryWith :: (Exception e, MonadUnliftIO m) => Scope -> ThreadOptions -> m a -> m (Thread (Either e a))
- data ThreadOptions = ThreadOptions {}
- defaultThreadOptions :: ThreadOptions
- data ThreadAffinity
- = Unbound
- | Capability Int
- | OsThread
- data ByteCount
- kilobytes :: Natural -> ByteCount
- megabytes :: Natural -> ByteCount
Documentation
A scope.
👉 Details
- A scope delimits the lifetime of all threads created within it.
- A scope is only valid during the callback provided to
scoped. - The thread that creates a scope is considered the parent of all threads created within it.
- All threads created within a scope can be awaited together (see
awaitAll). - All threads created within a scope are terminated when the scope closes.
A thread.
👉 Details
- A thread's lifetime is delimited by the scope in which it was created.
- The thread that creates a scope is considered the parent of all threads created within it.
- If an exception is raised in a child thread, the child either propagates the exception to its parent (see
fork), or returns the exception as a value (seeforkTry). - All threads created within a scope are terminated when the scope closes.
scoped :: forall a m. MonadUnliftIO m => (Scope -> m a) -> m a Source #
forkWith :: forall a m. MonadUnliftIO m => Scope -> ThreadOptions -> m a -> m (Thread a) Source #
forkWith_ :: MonadUnliftIO m => Scope -> ThreadOptions -> m Void -> m () Source #
forkTryWith :: (Exception e, MonadUnliftIO m) => Scope -> ThreadOptions -> m a -> m (Thread (Either e a)) Source #
data ThreadOptions #
affinityThe affinity of a thread. A thread can be unbound, bound to a specific capability, or bound to a specific OS thread.
Default:
UnboundallocationLimitThe maximum number of bytes a thread may allocate before it is delivered an
AllocationLimitExceededexception. 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)labelThe label of a thread, visible in the event log (
+RTS -l).Default:
""(no label)maskingStateThe masking state a thread is created in. To unmask, use
unsafeUnmask.Default:
Unmasked
Constructors
| ThreadOptions | |
Fields | |
Instances
| Show ThreadOptions | |
Defined in Ki.Internal.Thread Methods showsPrec :: Int -> ThreadOptions -> ShowS # show :: ThreadOptions -> String # showList :: [ThreadOptions] -> ShowS # | |
| Eq ThreadOptions | |
Defined in Ki.Internal.Thread 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.Thread Methods showsPrec :: Int -> ThreadAffinity -> ShowS # show :: ThreadAffinity -> String # showList :: [ThreadAffinity] -> ShowS # | |
| Eq ThreadAffinity | |
Defined in Ki.Internal.Thread Methods (==) :: ThreadAffinity -> ThreadAffinity -> Bool # (/=) :: ThreadAffinity -> ThreadAffinity -> Bool # | |
A number of bytes.
Instances
| Show ByteCount | |
| Eq ByteCount | |
| Ord ByteCount | |