multitasking
Safe HaskellNone
LanguageGHC2021

Multitasking.Core

Synopsis

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

Instances details
Await Coordinator Source # 
Instance details

Defined in Multitasking.Core

Associated Types

type Payload Coordinator 
Instance details

Defined in Multitasking.Core

type Payload Coordinator Source # 
Instance details

Defined in Multitasking.Core

start :: MonadIO m => Coordinator -> IO a -> m (Task a) Source #

start is the main way to spin up new tasks. It will execute the given action in another thread and returns a Task.

newtype Task a Source #

A Task is a computation on another thread. Use await to wait for the task.

Constructors

Task (Thread a) 

Instances

Instances details
Functor Task Source # 
Instance details

Defined in Multitasking.Core

Methods

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

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

Await (Task a) Source # 
Instance details

Defined in Multitasking.Core

Associated Types

type Payload (Task a) 
Instance details

Defined in Multitasking.Core

type Payload (Task a) = a

Methods

await :: MonadSTM m => Task a -> m (Payload (Task a)) Source #

probe :: MonadSTM m => Task a -> m (Maybe (Payload (Task a))) Source #

type Payload (Task a) Source # 
Instance details

Defined in Multitasking.Core

type Payload (Task a) = a

awaitTask :: MonadSTM m => Task a -> m a 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

Instances

Instances details
Show ThreadOptions 
Instance details

Defined in Ki.Internal.ThreadOptions

Eq ThreadOptions 
Instance details

Defined in Ki.Internal.ThreadOptions

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.

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.