2020-04-20 17:53:27 +00:00
|
|
|
{- git-cat file handles pools
|
|
|
|
-
|
2021-09-24 17:16:13 +00:00
|
|
|
- Copyright 2020-2021 Joey Hess <id@joeyh.name>
|
2020-04-20 17:53:27 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Types.CatFileHandles (
|
|
|
|
CatFileHandles(..),
|
|
|
|
catFileHandlesNonConcurrent,
|
|
|
|
catFileHandlesPool,
|
2021-09-24 17:16:13 +00:00
|
|
|
CatMap(..),
|
|
|
|
emptyCatMap,
|
2020-04-20 17:53:27 +00:00
|
|
|
) where
|
|
|
|
|
|
|
|
import Control.Concurrent.STM
|
|
|
|
import qualified Data.Map as M
|
|
|
|
|
|
|
|
import Utility.ResourcePool
|
2021-09-24 17:16:13 +00:00
|
|
|
import Git.CatFile (CatFileHandle, CatFileMetaDataHandle)
|
2020-04-20 17:53:27 +00:00
|
|
|
|
|
|
|
data CatFileHandles
|
|
|
|
= CatFileHandlesNonConcurrent CatMap
|
|
|
|
| CatFileHandlesPool (TMVar CatMap)
|
|
|
|
|
2021-09-24 17:16:13 +00:00
|
|
|
data CatMap = CatMap
|
|
|
|
{ catFileMap :: M.Map FilePath (ResourcePool CatFileHandle)
|
|
|
|
, catFileMetaDataMap :: M.Map FilePath (ResourcePool CatFileMetaDataHandle)
|
|
|
|
}
|
|
|
|
|
|
|
|
emptyCatMap :: CatMap
|
|
|
|
emptyCatMap = CatMap M.empty M.empty
|
2020-04-20 17:53:27 +00:00
|
|
|
|
|
|
|
catFileHandlesNonConcurrent :: CatFileHandles
|
2021-09-24 17:16:13 +00:00
|
|
|
catFileHandlesNonConcurrent = CatFileHandlesNonConcurrent emptyCatMap
|
2020-04-20 17:53:27 +00:00
|
|
|
|
|
|
|
catFileHandlesPool :: IO CatFileHandles
|
2021-09-24 17:16:13 +00:00
|
|
|
catFileHandlesPool = CatFileHandlesPool <$> newTMVarIO emptyCatMap
|