From 63352e46a880985efbdfab2e539d0f4975960b94 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Sat, 26 Sep 2026 22:29:45 -0300 Subject: add session object and protocol with pinning --- lib/kernel/Session.ml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/kernel/Session.ml (limited to 'lib/kernel/Session.ml') diff --git a/lib/kernel/Session.ml b/lib/kernel/Session.ml new file mode 100644 index 0000000..75bf8c9 --- /dev/null +++ b/lib/kernel/Session.ml @@ -0,0 +1,27 @@ +module Make (S : Abstract.Storage.STORAGE) = struct + module SI = Storage.Make (S) + module B = Branch.Make (S) + + class session storage state = + object (self) + inherit Lifecycle.null + inherit Identity.of_id + method to_string = "session" + val storage : S.connection = storage + val state : Protocols.Session.state Atomic.t = Atomic.make state + method state = Atomic.get state + method pin state' = Atomic.set state state' + method protocols = Protocols.[Directory.make self; Session.make self] + method list = Ok (BatFingerTree.singleton "branch") + + method find = + function + | "branch" -> + SI.with_read storage (fun tx -> + B.load tx storage (Atomic.get state).Protocols.Session.snapshot ) + |> Result.map Option.some + | _ -> Ok None + end + + let make storage state = new session storage state |> Protocols.Handle.make +end -- cgit v1.2.3