summaryrefslogtreecommitdiff
path: root/src/Storage/Internal.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2021-12-06 22:25:46 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2021-12-07 21:25:38 +0100
commit709a4a3698cb7cf280dbcc63acf2824d88d1a8c6 (patch)
tree5fc0f2da8410b796e46e9ebdb91a3319c5f2fd9a /src/Storage/Internal.hs
parentd7a8706c3409d7666aa08620e3ae5982797bf0c9 (diff)
Storage: head watch with selector and unwatch function
Diffstat (limited to 'src/Storage/Internal.hs')
-rw-r--r--src/Storage/Internal.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Storage/Internal.hs b/src/Storage/Internal.hs
index d589c44..7e593f8 100644
--- a/src/Storage/Internal.hs
+++ b/src/Storage/Internal.hs
@@ -59,15 +59,29 @@ showParentStorage Storage { stParent = Just st } = "@" ++ show st
data StorageBacking c
= StorageDir { dirPath :: FilePath
- , dirWatchers :: MVar ([(HeadTypeID, INotify)], [((HeadTypeID, HeadID), Ref' c -> IO ())])
+ , dirWatchers :: MVar ([(HeadTypeID, INotify)], WatchList c)
}
| StorageMemory { memHeads :: MVar [((HeadTypeID, HeadID), Ref' c)]
, memObjs :: MVar (Map RefDigest BL.ByteString)
, memKeys :: MVar (Map RefDigest ScrubbedBytes)
- , memWatchers :: MVar [((HeadTypeID, HeadID), Ref' c -> IO ())]
+ , memWatchers :: MVar (WatchList c)
}
deriving (Eq)
+newtype WatchID = WatchID Int
+ deriving (Eq, Ord, Num)
+
+data WatchList c = WatchList
+ { wlNext :: WatchID
+ , wlList :: [WatchListItem c]
+ }
+
+data WatchListItem c = WatchListItem
+ { wlID :: WatchID
+ , wlHead :: (HeadTypeID, HeadID)
+ , wlFun :: Ref' c -> IO ()
+ }
+
newtype RefDigest = RefDigest (Digest Blake2b_256)
deriving (Eq, Ord, NFData, ByteArrayAccess)