diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-23 03:32:15 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-23 03:32:15 -0300 |
| commit | 882511dc8c0abded18ba6abdca64938db2652771 (patch) | |
| tree | d1ebc2896cf9bb939a89c10d626d19cd5d4f591e /lib/kernel/Lifecycle.ml | |
| parent | b4422c99e10a8daee452b22aea84cb1f68ae54bc (diff) | |
| download | RNT-882511dc8c0abded18ba6abdca64938db2652771.tar.gz RNT-882511dc8c0abded18ba6abdca64938db2652771.zip | |
lift retaining, membership and mode checks out of ephemeral relation
Diffstat (limited to '')
| -rw-r--r-- | lib/kernel/Lifecycle.ml | 12 | ||||
| -rw-r--r-- | lib/kernel/Lifecycle.mli | 10 |
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 |
