multitasking
Safe HaskellNone
LanguageGHC2021

Multitasking.Workers

Synopsis

Sink Task

data SinkTask a Source #

A SinkTask continously consumes values of type a. Multiples values can queue up if writeSinkTask is too fast.

Instances

Instances details
Await (SinkTask a) Source # 
Instance details

Defined in Multitasking.Workers

Associated Types

type Payload (SinkTask a) 
Instance details

Defined in Multitasking.Workers

type Payload (SinkTask a) = Void

Methods

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

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

type Payload (SinkTask a) Source # 
Instance details

Defined in Multitasking.Workers

type Payload (SinkTask a) = Void

startSink :: MonadIO m => Coordinator -> (a -> IO ()) -> m (SinkTask a) Source #

start a SinkTask. It will execute the given function until it is canceled.

putSinkTask :: MonadSTM m => SinkTask a -> a -> m () Source #

Feeds a new value to the sink task

Source Task

data SourceTask a Source #

A SourceTask is a task which continously produces values of type a. Multiples values can queue up to be consumed with readSourceTask.

Instances

Instances details
Await (SourceTask a) Source # 
Instance details

Defined in Multitasking.Workers

Associated Types

type Payload (SourceTask a) 
Instance details

Defined in Multitasking.Workers

type Payload (SourceTask a) Source # 
Instance details

Defined in Multitasking.Workers

startSource :: MonadIO m => Coordinator -> IO a -> m (SourceTask a) Source #

start a SourceTask with the given action. It will be executed forever to produce new values.

takeSourceTask :: MonadSTM m => SourceTask a -> m a Source #

Take a value from the SourceTask, waiting if there is no output.

drainSourceTask :: MonadSTM m => SourceTask a -> m (Maybe a) Source #

Get a value from the SourceTask. Returns immediately with Nothing if there is no output.

Pipe Task

data PipeTask a b Source #

A pipe task transforms values of type a to values of type b. Both ends can queue up.

Instances

Instances details
Await (PipeTask a b) Source # 
Instance details

Defined in Multitasking.Workers

Associated Types

type Payload (PipeTask a b) 
Instance details

Defined in Multitasking.Workers

type Payload (PipeTask a b) = Void

Methods

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

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

type Payload (PipeTask a b) Source # 
Instance details

Defined in Multitasking.Workers

type Payload (PipeTask a b) = Void

startPipe :: MonadIO m => Coordinator -> (a -> IO b) -> m (PipeTask a b) Source #

start a PipeTask with the given function. It will be executed continously.

putPipeTask :: MonadSTM m => PipeTask a b -> a -> m () Source #

Feeds new values to the pipe task

takePipeTask :: MonadSTM m => PipeTask a b -> m b Source #

Gets the output from the pipe task. Waits if there is output available yet.

drainPipeTask :: MonadSTM m => PipeTask a b -> m (Maybe b) Source #

Gets the output from the pipe task. Does not wait for output.