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

Safe HaskellSafe-Inferred

Control.Concurrent.Bag.Concurrent

Description

This is a low-level interface to the bag of tasks. This implementation does not use stm in contrast to the other implementation. This implementation is provided for performance comparision. This implementation should only be used if it is not possible to use Control.Concurrent.Bag.SafeConcurrent for your task. This module allows more control but it also requires a deeper knowledge about the implementation.

Synopsis

Documentation

data Bag r Source

newBag_ :: MonadIO m => BufferType -> m (Bag r)Source

Create a new bag and use the number of capabilities as the thread count.

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

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

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

writeResult :: MonadIO m => Bag r -> r -> m ()Source

terminateBag :: MonadIO m => Bag 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 r -> m ()Source

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