-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Extends the threads package with a bounded thread group
--   
--   Extends the threads package with a bounded thread group with the same
--   interface as the original thread group.
@package threads-extras
@version 0.1.0.2


-- | This module wraps Control.Concurrent.Thread.Group and provides a
--   bounded version of ThreadGroup, mainly <a>BoundedThreadGroup</a>.
--   
--   In addition to the functionality of <a>ThreadGroup</a>,
--   <a>BoundedThreadGroup</a> will block creation of threads until there
--   fewer than the given max size.
module Control.Concurrent.Thread.BoundedThreadGroup

-- | A <a>BoundedThreadGroup</a> extends the concept of a
--   <a>ThreadGroup</a> by restricting the number of active threads to a
--   given max size. If one attempts to create more than the max size
--   number of threads the fork function will block until threads finish.
data BoundedThreadGroup
BoundedThreadGroup :: Int -> ThreadGroup -> BoundedThreadGroup
[maxSize] :: BoundedThreadGroup -> Int
[threadGroup] :: BoundedThreadGroup -> ThreadGroup

-- | Create a new <a>BoundedThreadGroup</a> with the passed in max size
new :: Int -> IO BoundedThreadGroup

-- | Same as Control.Concurrent.Thread.Group.nrOfRunning
nrOfRunning :: BoundedThreadGroup -> STM Int

-- | Same as Control.Concurrent.Thread.Group.wait
wait :: BoundedThreadGroup -> IO ()

-- | Same as Control.Concurrent.Thread.Group.waitN
waitN :: Int -> BoundedThreadGroup -> IO ()

-- | Same as Control.Concurrent.Thread.Group.forkIO but waits there are
--   less then the max size number of threads.
forkIO :: BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a))

-- | Same as Control.Concurrent.Thread.Group.forkOS but waits there are
--   less then the max size number of threads.
forkOS :: BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a))

-- | Same as Control.Concurrent.Thread.Group.forkOn but waits there are
--   less then the max size number of threads.
forkOn :: Int -> BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a))

-- | Same as Control.Concurrent.Thread.Group.forkIOWithUnmask but waits
--   there are less then the max size number of threads.
forkIOWithUnmask :: BoundedThreadGroup -> ((forall b. IO b -> IO b) -> IO a) -> IO (ThreadId, IO (Result a))

-- | Same as Control.Concurrent.Thread.Group.forkOnWithUnmask but waits
--   there are less then the max size number of threads.
forkOnWithUnmask :: Int -> BoundedThreadGroup -> ((forall b. IO b -> IO b) -> IO a) -> IO (ThreadId, IO (Result a))
