[ocaml-ctypes] Lifecycle of a callback?
trevorsummerssmith at gmail.com
Tue Oct 21 13:24:41 BST 2014
In the libuv bindings I am working on there is need for user callbacks. A
user registers the callback with a function, and then at an arbitrary point
in time later, the callback code is actually ran (started when the user
starts the libuv event loop). I had naively thought that I would need to
keep a reference to the user callback and then release this reference after
the user callback was actually called (because the callback would be used
at an arbitrary point in the future and could get gc'd).
I made an example this morning to test this out, however I cannot get it to
fail (ie throw an CallToExpiredClosure).
Perhaps my assumption is wrong, and I do not have to keep around a
reference? Or my test is not testing what I think it is?
I see similar discussion that doesn't have a clear resolution here:
My test code is here:
Test it: make && make tests # valgrind seems happy with it
I am running with libuv-1.0.0-rc1
https://github.com/joyent/libuv/tree/v1.0.0-rc1/ OCaml 18.104.22.168 and on a Mac
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ctypes