annex.jobs

Added annex.jobs setting, which is like using the -J option.

Of course, -J overrides annex.jobs.

This commit was sponsored by Trenton Cronholm on Patreon.
This commit is contained in:
Joey Hess 2018-10-04 12:47:27 -04:00
parent 585e6b39aa
commit 6ba3dea566
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 46 additions and 17 deletions

View file

@ -170,20 +170,32 @@ callCommandActionQuiet = start
{- Do concurrent output when that has been requested. -}
allowConcurrentOutput :: Annex a -> Annex a
#ifdef WITH_CONCURRENTOUTPUT
allowConcurrentOutput a = go =<< Annex.getState Annex.concurrency
allowConcurrentOutput a = do
fromcmdline <- Annex.getState Annex.concurrency
fromgitcfg <- annexJobs <$> Annex.getGitConfig
case (fromcmdline, fromgitcfg) of
(NonConcurrent, NonConcurrent) -> a
(Concurrent n, _) -> goconcurrent n
(NonConcurrent, Concurrent n) -> do
Annex.changeState $
\c -> c { Annex.concurrency = fromgitcfg }
goconcurrent n
where
go NonConcurrent = a
go (Concurrent _) = ifM (liftIO concurrentOutputSupported)
( Regions.displayConsoleRegions $
goconcurrent True
, goconcurrent False
)
goconcurrent b = bracket_ (setup b) cleanup a
setup = setconcurrentenabled
goconcurrent n = do
c <- liftIO getNumCapabilities
when (n > c) $
liftIO $ setNumCapabilities n
ifM (liftIO concurrentOutputSupported)
( Regions.displayConsoleRegions $
goconcurrent' True
, goconcurrent' False
)
goconcurrent' b = bracket_ (setup b) cleanup a
setup = setconcurrentoutputenabled
cleanup = do
finishCommandActions
setconcurrentenabled False
setconcurrentenabled b = Annex.changeState $ \s ->
setconcurrentoutputenabled False
setconcurrentoutputenabled b = Annex.changeState $ \s ->
s { Annex.output = (Annex.output s) { concurrentOutputEnabled = b } }
#else
allowConcurrentOutput = id

View file

@ -13,7 +13,6 @@ import Options.Applicative
#if ! MIN_VERSION_optparse_applicative(0,14,1)
import Options.Applicative.Builder.Internal
#endif
import Control.Concurrent
import qualified Data.Map as M
import Annex.Common
@ -370,11 +369,7 @@ jobsOption =
)
]
where
set n = do
Annex.changeState $ \s -> s { Annex.concurrency = Concurrent n }
c <- liftIO getNumCapabilities
when (n > c) $
liftIO $ setNumCapabilities n
set n = Annex.changeState $ \s -> s { Annex.concurrency = Concurrent n }
timeLimitOption :: [GlobalOption]
timeLimitOption =