Closed cjoynes closed 2 years ago
Ben - this can be done by adding a mexAtExit function (see mglPrivateOpen.c). Perhaps in mglSocketCreateClient?
Good call, I added a cleanup callback in e6b4b81a1a4b8f79510aa9c8a1cb8e6ecad5c189.
I'm trying a slightly different approach with an onCleanup callback.
So now mglMetalOpen stores a cleanup callback in the global mgl struct. Whenever the mgl struct gets cleared, the callback will also shut down any mglMetal process. This should happen at times like
This lets us define the cleanup handler in the same file where we're starting the mglMetal process. If one day we have multiple mglMetal processes at the same time, this should also let us manage them and clean them up individually.
It would be nice to have Matlab call mglClose when exiting so mglMetal isn’t open without an associated Matlab instance.