I am working on FFI bindings to C++ code that associates several memory pools
to each thread using the library. When a thread is done using the library, it
can call a C function to release the memory pool objects.
In the Haskell bindings, I’d like to be able to attach a finalizer that called
this cleanup code whenever an RTS OS thread is shutdown. It appeared that the
main place that happens is here:
https://github.com/ghc/ghc/blob/master/rts/Capability.c#L562-L577
I did not see a way to register a finalizer that is run before the call to
shutdownThread. Could this be something worth adding to the RTS?
It seems like the most straightforward way would be to add a finalizer list to
each task object, and expose a C function for adding callbacks to it.
As a fallback, it should be possible to modify the memory pools in the C++ code
so that they can be disabled. According to the author of the C++ code, this
should have about a 10% slowdown on execution, so it would be nice if I could
keep them enabled without a risk of memory leaks.
Regards,
Joe
_______________________________________________
ghc-devs mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs