From a4437f0479a721aeebac305e403b88b18a5f7d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 17 Jun 2020 22:30:47 +0200 Subject: Storage: typed heads --- src/Storage/Internal.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/Storage/Internal.hs') 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) -- cgit v1.2.3