check-ignore resource pool

Much like check-attr before.
This commit is contained in:
Joey Hess 2020-04-21 11:20:10 -04:00
parent 45fb7af21c
commit 04352ed9c5
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 66 additions and 27 deletions

View file

@ -0,0 +1,23 @@
{- git-annex concurrency utilities
-
- Copyright 2020 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Annex.Concurrent.Utility where
import Types.Concurrency
import GHC.Conc
{- Honor the requested level of concurrency, but only up to the number of
- CPU cores. Useful for things that are known to be CPU bound. -}
concurrencyUpToCpus :: Concurrency -> IO Int
concurrencyUpToCpus c = do
let cn = case c of
Concurrent n -> n
NonConcurrent -> 1
ConcurrentPerCpu -> 1
pn <- getNumProcessors
return (min cn pn)