summaryrefslogtreecommitdiff
path: root/src/Erebos/Storage/Backend.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-12-07 20:01:55 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2024-12-28 12:34:09 +0100
commit6cc15c6cd859070fda1b46995108fbfc3e13a5db (patch)
tree220870f1511aa65553d8fcbe79fd74d8280f1b65 /src/Erebos/Storage/Backend.hs
parent16876457bc526e22c64d024cd76c188dd5ba62c6 (diff)
StorageBackend type class
Changelog: API: Added `StorageBackend` type class to allow custom storage implementation
Diffstat (limited to 'src/Erebos/Storage/Backend.hs')
-rw-r--r--src/Erebos/Storage/Backend.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Erebos/Storage/Backend.hs b/src/Erebos/Storage/Backend.hs
new file mode 100644
index 0000000..620d423
--- /dev/null
+++ b/src/Erebos/Storage/Backend.hs
@@ -0,0 +1,28 @@
+{-|
+Description: Implement custom storage backend
+
+Exports type class, which can be used to create custom 'Storage' backend.
+-}
+
+module Erebos.Storage.Backend (
+ StorageBackend(..),
+ Complete, Partial,
+ Storage, PartialStorage,
+ newStorage,
+
+ WatchID, startWatchID, nextWatchID,
+) where
+
+import Control.Concurrent.MVar
+
+import Data.HashTable.IO qualified as HT
+
+import Erebos.Object.Internal
+import Erebos.Storage.Internal
+
+
+newStorage :: StorageBackend bck => bck -> IO (Storage' (BackendCompleteness bck))
+newStorage stBackend = do
+ stRefGeneration <- newMVar =<< HT.new
+ stRefRoots <- newMVar =<< HT.new
+ return Storage {..}