diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-08-23 17:03:40 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-08-23 17:03:40 +0000 |
| commit | 9efb32195a905de2d66ce29164cc22970833c2d7 (patch) | |
| tree | 2d69b4d5c4dc13b81e239418d8c4ee34731c59c4 /lib/kernel/Storage.ml | |
| parent | 997f3c6c039fd73de26df9f2d2cc1afa9f2677b4 (diff) | |
| download | RNT-9efb32195a905de2d66ce29164cc22970833c2d7.tar.gz RNT-9efb32195a905de2d66ce29164cc22970833c2d7.zip | |
Typed storage pointers
Diffstat (limited to '')
| -rw-r--r-- | lib/kernel/Storage.ml | 12 | ||||
| -rw-r--r-- | lib/kernel/Storage.mli | 9 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/kernel/Storage.ml b/lib/kernel/Storage.ml index 376d839..e6a84ba 100644 --- a/lib/kernel/Storage.ml +++ b/lib/kernel/Storage.ml @@ -1,4 +1,16 @@ module Make (S : Abstract.Storage.STORAGE) = struct + module Pointer = struct + type 'a t = { + addr : S.address; + loader : S.transaction -> S.address -> ('a, Concepts.Condition.condition) result + } + + let make addr loader = { addr; loader } + let address_of { addr; _ } = addr + let swap { loader; _ } addr = make addr loader + let deref tx { addr; loader } = loader tx addr + end + let finish tx = function | Ok value -> let open Utilities.Result in diff --git a/lib/kernel/Storage.mli b/lib/kernel/Storage.mli index 1148fba..9a10984 100644 --- a/lib/kernel/Storage.mli +++ b/lib/kernel/Storage.mli @@ -1,4 +1,13 @@ module Make : functor (S : Abstract.Storage.STORAGE) -> sig + module Pointer : sig + type 'a t + + val make : S.address -> (S.transaction -> S.address -> ('a, Concepts.Condition.condition) result) -> 'a t + val address_of : 'a t -> S.address + val swap : 'a t -> S.address -> 'a t + val deref : S.transaction -> 'a t -> ('a, Concepts.Condition.condition) result + end + val finish : S.transaction -> ('a, Concepts.Condition.condition) result -> ('a, Concepts.Condition.condition) result val with_transaction : S.connection -> (S.transaction -> ('a, Concepts.Condition.condition) result) -> ('a, Concepts.Condition.condition) result val store_blob : S.transaction -> Concepts.Blob.t -> (Concepts.Hash.hash, Concepts.Condition.condition) result |
