octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: oct file destructor?


From: John W. Eaton
Subject: Re: oct file destructor?
Date: Mon, 12 Feb 2018 15:13:09 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 02/12/2018 02:48 AM, Mike Miller wrote:
Hi,

Is there a way to register a destructor to be called when an oct file is
unloaded (via "clear all" or "clear functions")? Does anyone have any
thoughts on how to implement such a thing or a good pattern to follow?

I was thinking of trying a class destructor of a static object as a
stand in, something like

   struct cleanup_object
   {
     cleanup_object () {}
     ~cleanup_object () { uninitialize_something_important (); }
   };

   static cleanup_object obj;

Other suggestions? Thanks,

If the static object works for you, then maybe that's the simplest thing to do? Otherwise, we could maybe add something that would call a function when Octave unloads the shared library. Either in the dynamic_library class (lowest level) or in the dynamic_loader class (higher level, closer to .oct/.mex files).

jwe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]