ki-unlifted-1.0.0.2: A lightweight structured concurrency library
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Documentation

data Scope #

A scope.

👉 Details

Expand
  • 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.

data Thread a #

A thread.

👉 Details

Expand
  • 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 (see forkTry).
  • All threads created within a scope are terminated when the scope closes.

Instances

Instances details
Functor Thread 
Instance details

Defined in Ki.Internal.Thread

Methods

fmap :: (a -> b) -> Thread a -> Thread b #

(<$) :: a -> Thread b -> Thread a #

Eq (Thread a) 
Instance details

Defined in Ki.Internal.Thread

Methods

(==) :: Thread a -> Thread a -> Bool #

(/=) :: Thread a -> Thread a -> Bool #

Ord (Thread a) 
Instance details

Defined in Ki.Internal.Thread

Methods

compare :: Thread a -> Thread a -> Ordering #

(<) :: Thread a -> Thread a -> Bool #

(<=) :: Thread a -> Thread a -> Bool #

(>) :: Thread a -> Thread a -> Bool #

(>=) :: Thread a -> Thread a -> Bool #

max :: Thread a -> Thread a -> Thread a #

min :: Thread a -> Thread a -> Thread a #

scoped :: forall a m. MonadUnliftIO m => (Scope -> m a) -> m a Source #

fork :: forall a m. MonadUnliftIO m => Scope -> m a -> m (Thread a) Source #

forkTry :: (Exception e, MonadUnliftIO m) => Scope -> m a -> m (Thread (Either e a)) Source #

await :: Thread a -> STM a #

Wait for a thread to terminate.

awaitAll :: Scope -> STM () #

Wait until all threads created within a scope terminate.

fork_ :: MonadUnliftIO m => Scope -> m Void -> m () Source #

forkWith :: forall a m. MonadUnliftIO m => Scope -> ThreadOptions -> m a -> m (Thread a) Source #

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

Instances

Instances details
Show ThreadOptions 
Instance details

Defined in Ki.Internal.Thread

Eq ThreadOptions 
Instance details

Defined in Ki.Internal.Thread

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

Instances details
Show ThreadAffinity 
Instance details

Defined in Ki.Internal.Thread

Eq ThreadAffinity 
Instance details

Defined in Ki.Internal.Thread

data ByteCount #

A number of bytes.

Instances

Instances details
Show ByteCount 
Instance details

Defined in Ki.Internal.ByteCount

Eq ByteCount 
Instance details

Defined in Ki.Internal.ByteCount

Ord ByteCount 
Instance details

Defined in Ki.Internal.ByteCount

kilobytes :: Natural -> ByteCount #

A number of kilobytes.

megabytes :: Natural -> ByteCount #

A number of megabytes.