gang-of-threads-2.0.0: Non-deterministic parallelism with bags

Safe HaskellSafe-Inferred

Control.Concurrent.Bag.Basic

Description

This is a low-level interface to the bag of tasks, which should only be used if it is not possible to use Control.Concurrent.Bag.Safe for your task. This module allows more control but it also requires a deeper knowledge about the implementation.

Synopsis

Documentation

data Bag b r Source

addEval :: (MonadIO m, TaskBufferSTM b) => Bag b r -> r -> m ()Source

addTask :: (MonadIO m, TaskBufferSTM b) => Bag b r -> IO (Maybe r) -> m ()Source

getResult :: (MonadIO m, TaskBufferSTM b) => Bag b r -> m (Maybe r)Source

terminateBag :: MonadIO m => Bag b r -> m ()Source

Terminates all threads running in the thread pool. terminateBag is non-blocking and therefore does not guarantee that all threads are terminated after its executions. Additionally it is not guaranteed that the treads are terminated promptly. It is implemented using asynchronous exceptions and therefore it terminates a thread once it uses a safe point. A safe point is where memory allocation occurs. Although most tasks will have some point of memory allocation now and the, there are loops that will never reach a safe point.

noMoreTasks :: MonadIO m => Bag b r -> m ()Source

Tell the bag that there will be no more tasks from the outside, however, queued tasks may still add new tasks.

class TaskBufferSTM b whereSource

Methods

newBufferSTM :: STM (b a)Source

writeBufferSTM :: b a -> a -> STM ()Source

unGetBufferSTM :: b a -> a -> STM ()Source

Put the data back into the buffer. The item will be the next item read.

readBufferSTM :: b a -> STM aSource

tryReadBufferSTM :: b a -> STM (Maybe a)Source

isEmptyBufferSTM :: b a -> STM BoolSource

splitVertical :: SplitFunction b rSource

splitHalf :: SplitFunction b rSource

type SplitFunction b r = b (IO (Maybe r)) -> b (IO (Maybe r)) -> STM (IO (Maybe r))Source

takeFirst :: TaskBufferSTM b => b (IO (Maybe r)) -> b (IO (Maybe r)) -> STM (IO (Maybe r))Source