-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Concurrent utilities -- -- Release notes for version 0.5.0.0: -- -- @package ConcurrentUtils @version 0.5.0.0 module Control.CUtils.Channel type Channel = Chan module Control.CUtils.Dyn data Dyn value :: Typeable t => Dyn -> Maybe t makeDyn :: (Eq t, Show t, Typeable t) => t -> Dyn determineType :: Dyn -> TypeRep instance GHC.Classes.Eq Control.CUtils.Dyn.Dyn instance GHC.Show.Show Control.CUtils.Dyn.Dyn -- | Functional channels | A channel data type which allows consumers to -- hold references to different points in a stream at the same time. -- Elements of a channel are kept alive only so long as there are -- references pointing before those elements; producers on a channel are -- kept alive only so long as there are consumers. module Control.CUtils.FChan data Chan t -- | Construct a channel from a list. listToChan :: [t] -> Chan t chanContents :: Chan t -> IO [t] -- | Thrown by the writer function. data DoneReadingException DoneReadingException :: DoneReadingException -- | Take the first element from a channel, and a channel representing the -- remainder of the output. takeChan :: () => Chan t -> IO (t, Chan t) tryTakeChan :: () => Chan t -> IO (Maybe (t, Chan t)) -- | Create a new channel. The first return value is a function that can be -- used to add values to the channel. The second return value is the -- channel itself. newChan :: () => IO (t -> IO (), Chan t) -- | The first return value is a procedure that returns values from the -- channel successively, starting from the position of the parameter -- channel. The second thunk can be used to retrieve the position of the -- channel after the reads made using the first thunk. makeConsumer :: () => Chan b -> IO (IO b, IO (Chan b)) -- | Create a channel which is initially empty, but accumulates new -- elements. dupChan :: () => Chan a -> IO (Chan a) instance GHC.Show.Show Control.CUtils.FChan.DoneReadingException instance GHC.Exception.Type.Exception Control.CUtils.FChan.DoneReadingException module Control.CUtils.BoundedQueue data BoundedQueue t newRB :: MVector MVector t => Int -> IO (BoundedQueue t) writeRB :: BoundedQueue t -> t -> IO () readRB :: BoundedQueue t -> IO t -- | Read the maximum size of the bounded queue. lengthRB :: BoundedQueue t -> Int -- | Snapshot buffer size. getSizeRB :: BoundedQueue t -> IO Int instance Data.Typeable.Internal.Typeable t => Data.Data.Data (Control.CUtils.BoundedQueue.BoundedQueue t) module Control.CUtils.StrictArrow type ProfunctorOptic a t u v w = a v w -> a t u forceDef :: ArrowApply a => ProfunctorOptic a t u t u -- | Arrows that have a strictness effect. class (Arrow a) => Strict a -- | Laws: -- -- -- -- These laws place limitations on the effects that force can -- introduce. Reynolds' parametricity also implies that force does -- not change the argument and return values. force :: Strict a => ProfunctorOptic a t u t u evalInFst :: (t, u) -> (t, u) instance Control.CUtils.StrictArrow.Strict (->) instance GHC.Base.Monad f => Control.CUtils.StrictArrow.Strict (Control.Arrow.Kleisli f) instance Control.CUtils.StrictArrow.Strict a => Control.CUtils.StrictArrow.Strict (Control.Arrow.Reader.ReaderT r a) instance Control.CUtils.StrictArrow.Strict a => Control.CUtils.StrictArrow.Strict (Control.Arrow.State.StateT s a) instance (Control.CUtils.StrictArrow.Strict a, GHC.Base.Monoid w) => Control.CUtils.StrictArrow.Strict (Control.Arrow.Writer.WriterT w a) instance (Control.CUtils.StrictArrow.Strict a, Control.Arrow.ArrowChoice a) => Control.CUtils.StrictArrow.Strict (Control.Arrow.Abort.AbortT r a) module Control.CUtils.ThreadPool data Pool addToPoolMulti :: Pool -> IO t -> IO () newPool :: Int -> IO Pool -- | Stop each worker thread in turn by sending it a message. stopPool_ :: Pool -> IO () globalPool :: Pool -- | Thread pools support some standard operations.... class ThreadPool pool addToPool :: ThreadPool pool => pool -> IO t -> IO () class Interruptible pool stopPool :: Interruptible pool => pool -> IO () -- | Use if you don't want to use a thread pool. The implementation of -- addToPool spawns a green thread. data NoPool NoPool :: NoPool data BoxedThreadPool [BoxedThreadPool] :: ThreadPool pool => pool -> BoxedThreadPool instance Data.Data.Data Control.CUtils.ThreadPool.NoPool instance Data.Data.Data Control.CUtils.ThreadPool.Pool instance Control.CUtils.ThreadPool.ThreadPool Control.CUtils.ThreadPool.BoxedThreadPool instance Control.CUtils.ThreadPool.ThreadPool Control.CUtils.ThreadPool.NoPool instance Control.CUtils.ThreadPool.Interruptible Control.CUtils.ThreadPool.Pool instance Control.CUtils.ThreadPool.ThreadPool Control.CUtils.ThreadPool.Pool instance Data.Data.Data Control.CUtils.ThreadPool.Worker instance Data.Data.Data Control.CUtils.ThreadPool.Instruction -- | A module of concurrent higher order functions. module Control.CUtils.CPUMultiThreading -- | For exceptions caused by caller code. data ExceptionList ExceptionList :: [SomeException] -> ExceptionList -- | For internal errors. If a procedure throws this, some threads it -- created may still be running. This exception type is provided out of -- an abundance of caution, in case you want to take precautions against -- the activities of threads that for whatever reason cannot be -- terminated. If thrown it is never among the exceptions listed inside -- an ExceptionList. data ConcException ConcException :: ConcException -- | A type for methods that accept a list of tasks. type ConcurrentMethod t t2 = Over (Kleisli ((->) Int)) IO () t () t2 -- | A type for functions that transform a base method, taking a thread -- pool also. type ConcurrentMethodAdapter t t2 = Pool -> (Int -> ConcurrentMethod t t2) -> Int -> ConcurrentMethod t t2 -- | Run the collection of tasks in the specified thread pool. Each task -- does not necessarily get its own thread--a best effort is made to -- spread the load over all threads in the thread pool. simpleConc_ :: Foldable f => Pool -> f (IO ()) -> () -> IO () -- | This function implements some policy for simpleConc_. -- simpleConc_ makes the guarantee that the tasks given as an -- argument, map one-to-one to the tasks run on the thread pool. This -- guarantee is dropped for the function concurrent_, which allows -- more optimization. -- -- In order to get the tasks, the integer argument n is accepted -- and the functional mnds is evaluated in the range 0 to n-1 -- inclusive. concurrent_ :: Pool -> Int -> ConcurrentMethod () t -- | An adapter which modifies the argument concurrent method, to implement -- an exception handling policy in which exceptions are collected in a -- list, which is thrown as an exception in the caller. This appropriates -- the exception handling behavior of old versions of this package. throwToCallerAdapter_ :: Pool -> (t1 -> ConcurrentMethod () ()) -> t1 -> ConcurrentMethod () () toNewStyle :: ((Int -> IO t2) -> IO t) -> ConcurrentMethod t t2 instance GHC.Show.Show Control.CUtils.CPUMultiThreading.ConcException instance GHC.Show.Show Control.CUtils.CPUMultiThreading.ExceptionList instance GHC.Exception.Type.Exception Control.CUtils.CPUMultiThreading.ConcException instance GHC.Exception.Type.Exception Control.CUtils.CPUMultiThreading.ExceptionList module Control.CUtils.AssociativeFold -- | Concurrent evaluation of an associative fold. The caller is -- responsible for introducing appropriate strictness for the results in -- the second argument. assocFold :: forall t. Pool -> (t -> t -> IO t) -> Int -> (Int -> t) -> IO t -- | Pattern which is a simple wrapper around assocFold. assocFold_pattern :: Pool -> (t -> t -> IO t) -> Int -> (Int -> IO t) -> IO t -- | Compatibility shims for old version module Control.CUtils.Conc -- | For exceptions caused by caller code. data ExceptionList ExceptionList :: [SomeException] -> ExceptionList -- | For internal errors. If a procedure throws this, some threads it -- created may still be running. This exception type is provided out of -- an abundance of caution, in case you want to take precautions against -- the activities of threads that for whatever reason cannot be -- terminated. If thrown it is never among the exceptions listed inside -- an ExceptionList. data ConcException ConcException :: ConcException concF_ :: ?pool :: Pool => Int -> ConcurrentMethod () () conc_ :: (IArray ar (IO ()), Ix i, ?pool :: Pool) => ar i (IO ()) -> IO () concF :: ?pool :: Pool => Int -> ConcurrentMethod (Array Int t) t -- | Runs several computations concurrently, and returns their results as -- an array. Waits for all threads to end before returning. conc :: (IArray ar (IO e), Ix i, ?pool :: Pool) => ar i (IO e) -> IO (Array i e) arr_assocFold :: (IArray ar t, Ix i, ?pool :: Pool) => Kleisli IO (u, u) u -> (t -> u) -> Kleisli IO (t, ar i t) u