From f87767c3e5b0f1920a6179d5cd0d4613cca92658 Mon Sep 17 00:00:00 2001 From: Estevan Castilho Date: Sat, 29 Aug 2026 01:14:27 +0000 Subject: Make registration more like a CAS --- lib/protocols/Registry.ml | 7 ++----- lib/protocols/Registry.mli | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/protocols/Registry.ml b/lib/protocols/Registry.ml index 4c47001..f01f06b 100644 --- a/lib/protocols/Registry.ml +++ b/lib/protocols/Registry.ml @@ -1,6 +1,5 @@ class type implementation = object - method register : string -> Handle.t -> (unit, Concepts.Condition.condition) result - method unregister : string -> (unit, Concepts.Condition.condition) result + method update : string -> Handle.t option -> Handle.t option -> (bool, Concepts.Condition.condition) result end type Handle.protocol += Registry of implementation @@ -11,6 +10,4 @@ let make impl = Registry (impl :> implementation) let from handle = Handle.into handle (function Registry impl -> Some impl | _ -> None) -let register i key value = Handle.invoke i (fun o -> o#register key value) - -let unregister i key = Handle.invoke i (fun o -> o#unregister key) +let update i key reference value = Handle.invoke i (fun o -> o#update key reference value) diff --git a/lib/protocols/Registry.mli b/lib/protocols/Registry.mli index 175ebed..3390167 100644 --- a/lib/protocols/Registry.mli +++ b/lib/protocols/Registry.mli @@ -1,13 +1,11 @@ type t class type implementation = object - method register : string -> Handle.t -> (unit, Concepts.Condition.condition) result - method unregister : string -> (unit, Concepts.Condition.condition) result + method update : string -> Handle.t option -> Handle.t option -> (bool, Concepts.Condition.condition) result end val make : #implementation -> Handle.protocol val from : Handle.t -> t Handle.interface option -val register : t Handle.interface -> string -> Handle.t -> (unit, Concepts.Condition.condition) result -val unregister : t Handle.interface -> string -> (unit, Concepts.Condition.condition) result +val update : t Handle.interface -> string -> Handle.t option -> Handle.t option -> (bool, Concepts.Condition.condition) result -- cgit v1.2.3