Portability | POSIX |
---|---|
Stability | experimental |
Maintainer | bastianholst@gmx.de |
Safe Haskell | Safe-Inferred |
Task implementations Interruptible
and TaskIO
. These can be use by some of
the bag of tasks interfaces such as Control.Concurrent.Bag.Implicit
and Control.Concurrent.Bag.ImplicitConcurrent.
- data TaskIO r a
- runTaskIO :: TaskIO r (Maybe r) -> AddTask r -> WriteResult r -> IO (Maybe r)
- addTaskIO :: TaskIO r (Maybe r) -> TaskIO r ()
- writeResult :: r -> TaskIO r ()
- data Interruptible r
- = NoResult
- | OneResult r
- | AddInterruptibles [Interruptible r]
- runInterrupted :: Interruptible r -> TaskIO r (Maybe r)
- runInterruptible :: Interruptible r -> TaskIO r (Maybe r)
- type WriteResult r = r -> IO ()
- type AddTask r = IO (Maybe r) -> IO ()
Documentation
A monad in which tasks can be specified.
Task is instancing MonadIO
and it therefore has the function liftIO
to
perform arbitrary IO actions. Tasks may or may not return a value. If it
returns a value, this value is written back as a result.
Additionally there is a function addTask
to
add new tasks to the bag.
The parameter r is the result type of the corresponding bag.
In contrast to Interruptible
the evaluation order is simililar to that of
the IO monad and tasks added by addTaskIO are added immediately.
:: TaskIO r (Maybe r) | The task to be run |
-> AddTask r | Function to add a new task |
-> WriteResult r | Function to write back a result |
-> IO (Maybe r) | Returns a value if the task did |
Run a task as an IO
action.
addTaskIO :: TaskIO r (Maybe r) -> TaskIO r ()Source
Add a task to the bag of tasks from another task. The task will be added immediately.
writeResult :: r -> TaskIO r ()Source
Write back a result from a task.
data Interruptible r Source
A type to specify interruptible tasks. Interruptible tasks are tasks that
can be interrupted and resumed later. Basically this means that the
evaluating thread may be killed in between. Side-effects in this code are
not allowed, and therefore all interrupted tasks have to be pure
functional in contrast to TaskIO
tasks. Otherwise this is similar to
TaskIO
.
runInterrupted :: Interruptible r -> TaskIO r (Maybe r)Source
Run the given interruptible task with interruptions.
Note: When using this function, it may be possible that some tasks are never completed, because the time to produce an intermediate result is longer than the interruption frequency.
runInterruptible :: Interruptible r -> TaskIO r (Maybe r)Source
Run the given interruptible task.
Run with this function, the task will not be interrupted.
type WriteResult r = r -> IO ()Source
Function to write back a result.