summaryrefslogtreecommitdiff
path: root/src/Erebos/Storage/Backend.hs
diff options
context:
space:
mode:
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 {..}