diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-10-10 00:32:21 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-10-10 00:32:21 +0000 |
| commit | ecd778d5d92dc7cd0b57b9eb78b509ab851f3474 (patch) | |
| tree | 1b8ef6d9c0994245064f26acd382038a946a974f /lib | |
| parent | 290be60cf34ef2550a8cb9aa447c232445cd1476 (diff) | |
| download | RNT-ecd778d5d92dc7cd0b57b9eb78b509ab851f3474.tar.gz RNT-ecd778d5d92dc7cd0b57b9eb78b509ab851f3474.zip | |
The finalizer should also release the handle
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/protocols/Handle.ml | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/protocols/Handle.ml b/lib/protocols/Handle.ml index 7f7fe95..fc226c0 100644 --- a/lib/protocols/Handle.ml +++ b/lib/protocols/Handle.ml @@ -26,6 +26,11 @@ let object_of {valid; refers_to; _} = let to_string h = let o = (object_of h) in "#<" ^ o#to_string ^ " " ^ (Concepts.Hash.to_hum_string o#hash) ^ ">" +let release ({valid; _} as handle) = + let o = object_of handle in + if Atomic.compare_and_set valid true false then + o#release + let on_gc ({valid; refers_to; allocated_at} as h) = (* TODO: get rid of this on release builds *) if refers_to#is_managed && (Atomic.get valid) then begin @@ -34,14 +39,10 @@ let on_gc ({valid; refers_to; allocated_at} as h) = (* bleh *) ~str:(Printexc.raw_backtrace_to_string allocated_at) ~sub:"Raised by primitive operation" - ~by:"Allocated")) + ~by:"Allocated")); + release h end -let release ({valid; _} as handle) = - let o = object_of handle in - if Atomic.compare_and_set valid true false then - o#release - type _ Effect.t += Autorelease: t -> unit Effect.t let with_autorelease f = |
