minor optimisation
Avoid a second mvar access. Sponsored-by: Jochen Bartl on Patreon
This commit is contained in:
parent
4b6cb2b917
commit
b3cd0cc6ba
1 changed files with 12 additions and 11 deletions
|
@ -55,19 +55,20 @@ commandActions = mapM_ commandAction
|
||||||
- This should only be run in the seek stage.
|
- This should only be run in the seek stage.
|
||||||
-}
|
-}
|
||||||
commandAction :: CommandStart -> Annex ()
|
commandAction :: CommandStart -> Annex ()
|
||||||
commandAction start = getConcurrency >>= \case
|
commandAction start = do
|
||||||
NonConcurrent -> runnonconcurrent
|
st <- Annex.getState id
|
||||||
Concurrent n
|
case getConcurrency' (Annex.concurrency st) of
|
||||||
| n > 1 -> runconcurrent
|
NonConcurrent -> runnonconcurrent
|
||||||
| otherwise -> runnonconcurrent
|
Concurrent n
|
||||||
ConcurrentPerCpu -> runconcurrent
|
| n > 1 -> runconcurrent (Annex.workers st)
|
||||||
|
| otherwise -> runnonconcurrent
|
||||||
|
ConcurrentPerCpu -> runconcurrent (Annex.workers st)
|
||||||
where
|
where
|
||||||
runnonconcurrent = void $ includeCommandAction start
|
runnonconcurrent = void $ includeCommandAction start
|
||||||
runconcurrent = Annex.getState Annex.workers >>= \case
|
runconcurrent Nothing = runnonconcurrent
|
||||||
Nothing -> runnonconcurrent
|
runconcurrent (Just tv) =
|
||||||
Just tv ->
|
liftIO (atomically (waitStartWorkerSlot tv)) >>=
|
||||||
liftIO (atomically (waitStartWorkerSlot tv)) >>=
|
maybe runnonconcurrent (runconcurrent' tv)
|
||||||
maybe runnonconcurrent (runconcurrent' tv)
|
|
||||||
runconcurrent' tv (workerstrd, workerstage) = do
|
runconcurrent' tv (workerstrd, workerstage) = do
|
||||||
aid <- liftIO $ async $ snd
|
aid <- liftIO $ async $ snd
|
||||||
<$> Annex.run workerstrd
|
<$> Annex.run workerstrd
|
||||||
|
|
Loading…
Reference in a new issue