diff libinterp/corefcn/interpreter.h @ 27689:4f32af6abd4b

don't use static variable for list of interpreter atexit functions * interpreter.h, interpreter.cc (atexit_functions): Delete static variable. (interpreter::m_atexit_fcns): New member variable. Replace all uses of old atexit_functions list with this variable. (Fatexit): Call new member functions instead of static functions. (interpreter::execute_atexit_fcns): New function. (interpreter::cleanup): Call execute_atexit_fcns instead of doing that job directly here. (interpreter::add_atexit_fcn, interpreter::remove_atexit_fcn): New member functions. (interpreter::add_atexit_function, interpreter::remove_atexit_function): Deprecate static functions. Call new member functions.
author John W. Eaton <jwe@octave.org>
date Thu, 14 Nov 2019 15:18:15 -0500
parents e091e09d26f0
children c81139d8dcc3
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.h	Thu Nov 14 11:14:25 2019 -0800
+++ b/libinterp/corefcn/interpreter.h	Thu Nov 14 15:18:15 2019 -0500
@@ -448,8 +448,14 @@
       return m_executing_finish_script;
     }
 
+    void add_atexit_fcn (const std::string& fname);
+
+    bool remove_atexit_fcn (const std::string& fname);
+
+    OCTAVE_DEPRECATED (6, "use interpreter::add_atexit_fcn member function instead")
     static void add_atexit_function (const std::string& fname);
 
+    OCTAVE_DEPRECATED (6, "use interpreter::remove_atexit_fcn member function instead")
     static bool remove_atexit_function (const std::string& fname);
 
     static interpreter * the_interpreter (void) { return instance; }
@@ -466,8 +472,6 @@
 
     OCTAVE_THREAD_LOCAL static interpreter *instance;
 
-    static std::list<std::string> atexit_functions;
-
     void display_startup_message (void) const;
 
     int execute_startup_files (void);
@@ -480,10 +484,14 @@
 
     void cleanup (void);
 
+    void execute_atexit_fcns (void);
+
     application *m_app_context;
 
     temporary_file_list m_tmp_files;
 
+    std::list<std::string> m_atexit_fcns;
+
     display_info m_display_info;
 
     environment m_environment;