2016-09-09 16:57:42 +00:00
|
|
|
{- Copyright 2016 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2016-09-09 16:57:42 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
module Types.Concurrency where
|
|
|
|
|
2019-05-10 17:24:31 +00:00
|
|
|
import Utility.PartialPrelude
|
|
|
|
|
2019-06-17 18:58:02 +00:00
|
|
|
-- 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.
|
2019-05-10 17:24:31 +00:00
|
|
|
data Concurrency = NonConcurrent | Concurrent Int | ConcurrentPerCpu
|
2020-04-20 17:53:27 +00:00
|
|
|
deriving (Eq)
|
2019-05-10 17:24:31 +00:00
|
|
|
|
|
|
|
parseConcurrency :: String -> Maybe Concurrency
|
|
|
|
parseConcurrency "cpus" = Just ConcurrentPerCpu
|
|
|
|
parseConcurrency "cpu" = Just ConcurrentPerCpu
|
|
|
|
parseConcurrency s = Concurrent <$> readish s
|
2020-09-16 15:41:28 +00:00
|
|
|
|
|
|
|
-- Concurrency can be configured at the command line or by git config.
|
|
|
|
data ConcurrencySetting
|
|
|
|
= ConcurrencyCmdLine Concurrency
|
|
|
|
| ConcurrencyGitConfig Concurrency
|