diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2020-06-17 22:30:47 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2020-06-17 22:30:47 +0200 |
commit | a4437f0479a721aeebac305e403b88b18a5f7d5f (patch) | |
tree | 075e7db76a5a0c2021dec61a8bad2620ad01fd08 /src/Storage | |
parent | b08e5a3e6d82ca5e5a2e29e791a2e61bf08964a4 (diff) |
Storage: typed heads
Diffstat (limited to 'src/Storage')
-rw-r--r-- | src/Storage/Internal.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Storage/Internal.hs b/src/Storage/Internal.hs index c70e8ae..e4e4f00 100644 --- a/src/Storage/Internal.hs +++ b/src/Storage/Internal.hs @@ -24,6 +24,7 @@ import qualified Data.HashTable.IO as HT import Data.List import Data.Map (Map) import qualified Data.Map as M +import Data.UUID (UUID) import Foreign.Storable (peek) @@ -57,12 +58,12 @@ showParentStorage Storage { stParent = Just st } = "@" ++ show st data StorageBacking c = StorageDir { dirPath :: FilePath - , dirWatchers :: MVar (Maybe INotify, [(String, Head' c -> IO ())]) + , dirWatchers :: MVar ([(HeadTypeID, INotify)], [((HeadTypeID, HeadID), Ref' c -> IO ())]) } - | StorageMemory { memHeads :: MVar [Head' c] + | StorageMemory { memHeads :: MVar [((HeadTypeID, HeadID), Ref' c)] , memObjs :: MVar (Map RefDigest BL.ByteString) , memKeys :: MVar (Map RefDigest ScrubbedBytes) - , memWatchers :: MVar [(String, Head' c -> IO ())] + , memWatchers :: MVar [((HeadTypeID, HeadID), Ref' c -> IO ())] } deriving (Eq) @@ -111,9 +112,15 @@ hashToRefDigest = RefDigest . hashFinalize . hashUpdates hashInit . BL.toChunks newtype Generation = Generation Int deriving (Eq, Show) -data Head' c = Head String (Ref' c) +data Head' c a = Head HeadID (Stored' c a) deriving (Show) +newtype HeadID = HeadID UUID + deriving (Eq, Ord, Show) + +newtype HeadTypeID = HeadTypeID UUID + deriving (Eq, Ord) + data Stored' c a = Stored (Ref' c) a deriving (Show) |