Hoogle Search

Within LTS Haskell 24.41 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. data ReleaseMap

    resourcet Control.Monad.Trans.Resource.Internal

    No documentation available.

  2. ReleaseMap :: NextKey -> RefCount -> !IntMap (ReleaseType -> IO ()) -> ReleaseMap

    resourcet Control.Monad.Trans.Resource.Internal

    No documentation available.

  3. ReleaseMapClosed :: ReleaseMap

    resourcet Control.Monad.Trans.Resource.Internal

    No documentation available.

  4. getIntMapOf :: Get Int -> Get a -> Get (IntMap a)

    cereal Data.Serialize.Get

    Read as a list of pairs of int and element.

  5. getMapOf :: Ord k => Get k -> Get a -> Get (Map k a)

    cereal Data.Serialize.Get

    Read as a list of pairs of key and element.

  6. putIntMapOf :: Putter Int -> Putter a -> Putter (IntMap a)

    cereal Data.Serialize.Put

    No documentation available.

  7. putMapOf :: Putter k -> Putter a -> Putter (Map k a)

    cereal Data.Serialize.Put

    No documentation available.

  8. data HashMap k v

    gogol-core Gogol.Prelude

    A map from keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

  9. pooledMapConcurrently :: (MonadUnliftIO m, Traversable t) => (a -> m b) -> t a -> m (t b)

    unliftio UnliftIO.Async

    Similar to pooledMapConcurrentlyN but with number of threads set from getNumCapabilities. Usually this is useful for CPU bound tasks.

  10. pooledMapConcurrentlyN :: (MonadUnliftIO m, Traversable t) => Int -> (a -> m b) -> t a -> m (t b)

    unliftio UnliftIO.Async

    Like mapConcurrently from async, but instead of one thread per element, it does pooling from a set of threads. This is useful in scenarios where resource consumption is bounded and for use cases where too many concurrent tasks aren't allowed.

    Example usage

    import Say
    
    action :: Int -> IO Int
    action n = do
    tid <- myThreadId
    sayString $ show tid
    threadDelay (2 * 10^6) -- 2 seconds
    return n
    
    main :: IO ()
    main = do
    yx <- pooledMapConcurrentlyN 5 (\x -> action x) [1..5]
    print yx
    
    On executing you can see that five threads have been spawned:
    $ ./pool
    ThreadId 36
    ThreadId 38
    ThreadId 40
    ThreadId 42
    ThreadId 44
    [1,2,3,4,5]
    
    Let's modify the above program such that there are less threads than the number of items in the list:
    import Say
    
    action :: Int -> IO Int
    action n = do
    tid <- myThreadId
    sayString $ show tid
    threadDelay (2 * 10^6) -- 2 seconds
    return n
    
    main :: IO ()
    main = do
    yx <- pooledMapConcurrentlyN 3 (\x -> action x) [1..5]
    print yx
    
    On executing you can see that only three threads are active totally:
    $ ./pool
    ThreadId 35
    ThreadId 37
    ThreadId 39
    ThreadId 35
    ThreadId 39
    [1,2,3,4,5]
    

Page 429 of many | Previous | Next