aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/Lifecycle.ml
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/kernel/Lifecycle.ml12
-rw-r--r--lib/kernel/Lifecycle.mli10
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/kernel/Lifecycle.ml b/lib/kernel/Lifecycle.ml
index 20282dd..772cb6e 100644
--- a/lib/kernel/Lifecycle.ml
+++ b/lib/kernel/Lifecycle.ml
@@ -26,3 +26,15 @@ class virtual counted = object (self)
if Atomic.fetch_and_add references (-1) = 1 then
self#destroy
end
+
+class retaining inner (owner : lifecycle) = object
+ inherit counted
+ initializer ignore owner#reference
+
+ method destroy =
+ Protocols.Handle.release inner;
+ owner#release
+
+ method hash = Protocols.Handle.hash inner
+ method protocols = Protocols.Handle.protocols inner
+end
diff --git a/lib/kernel/Lifecycle.mli b/lib/kernel/Lifecycle.mli
index f110768..fa3abee 100644
--- a/lib/kernel/Lifecycle.mli
+++ b/lib/kernel/Lifecycle.mli
@@ -10,3 +10,13 @@ end
class null : lifecycle
class virtual counted : controlled_lifecycle
+
+(** stands for [inner], carrying what it carries, while holding a
+ reference to [owner], so what [inner] reads outlives a release of
+ the object that produced it. *)
+class retaining : Protocols.Handle.t -> lifecycle -> object
+ inherit lifecycle
+ method destroy : unit
+ method hash : Concepts.Hash.hash
+ method protocols : Protocols.Handle.protocol list
+end