git-annex/Types/Concurrency.hs
Joey Hess 15d617f7e1
have setConcurrency stop any running git coprocesses
When non-concurrent git coprocesses have been started, setConcurrency
used to not stop them, and so could leak processes when enabling
concurrency, eg when forkState is called.

I do not think that ever actually happened, given where setConcurrency
is called. And it probably would only leak one of each process, since it
never downgrades from concurrent to non-concurrent.
2021-11-19 12:00:39 -04:00

25 lines
805 B
Haskell

{- Copyright 2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Types.Concurrency where
import Utility.PartialPrelude
-- Note that Concurrent 1 is not the same as NonConcurrent;
-- the former specifies 1 job of each particular kind, but there can be
-- more than one kind of job running concurrently.
data Concurrency = NonConcurrent | Concurrent Int | ConcurrentPerCpu
deriving (Eq)
parseConcurrency :: String -> Maybe Concurrency
parseConcurrency "cpus" = Just ConcurrentPerCpu
parseConcurrency "cpu" = Just ConcurrentPerCpu
parseConcurrency s = Concurrent <$> readish s
-- Concurrency can be configured at the command line or by git config.
data ConcurrencySetting
= ConcurrencyCmdLine Concurrency
| ConcurrencyGitConfig Concurrency
deriving (Eq)