Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module wraps Control.Concurrent.Thread.Group and provides a bounded
version of ThreadGroup, mainly BoundedThreadGroup
.
In addition to the functionality of ThreadGroup
, BoundedThreadGroup
will block creation of threads until there fewer than the given
max size.
Synopsis
- data BoundedThreadGroup = BoundedThreadGroup {
- maxSize :: Int
- threadGroup :: ThreadGroup
- new :: Int -> IO BoundedThreadGroup
- nrOfRunning :: BoundedThreadGroup -> STM Int
- wait :: BoundedThreadGroup -> IO ()
- waitN :: Int -> BoundedThreadGroup -> IO ()
- forkIO :: BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a))
- forkOS :: BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a))
- forkOn :: Int -> BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a))
- forkIOWithUnmask :: BoundedThreadGroup -> ((forall b. IO b -> IO b) -> IO a) -> IO (ThreadId, IO (Result a))
- forkOnWithUnmask :: Int -> BoundedThreadGroup -> ((forall b. IO b -> IO b) -> IO a) -> IO (ThreadId, IO (Result a))
Documentation
data BoundedThreadGroup Source #
A BoundedThreadGroup
extends the concept of a ThreadGroup
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.
new :: Int -> IO BoundedThreadGroup Source #
Create a new BoundedThreadGroup
with the passed in max size
nrOfRunning :: BoundedThreadGroup -> STM Int Source #
Same as Control.Concurrent.Thread.Group.nrOfRunning
wait :: BoundedThreadGroup -> IO () Source #
Same as Control.Concurrent.Thread.Group.wait
forkIO :: BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a)) Source #
Same as Control.Concurrent.Thread.Group.forkIO but waits there are less then the max size number of threads.
forkOS :: BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a)) Source #
Same as Control.Concurrent.Thread.Group.forkOS but waits there are less then the max size number of threads.
forkOn :: Int -> BoundedThreadGroup -> IO a -> IO (ThreadId, IO (Result a)) Source #
Same as Control.Concurrent.Thread.Group.forkOn but waits there are less then the max size number of threads.