Tuxedo : Using C++'s Constructors and Destructors

Tuxedo : Using C++'s Constructors and Destructors
 

C++ constructors are called to initialize class objects when those objects are created, and destructors are invoked when class objects are destroyed. For automatic (that is, local, non-static) variables that contain constructors and destructors, the constructor is called when the variable comes into scope and the destructor is called when the variable goes out of scope. However, when you call the tpreturn() or tpforward() function, the compiler performs a non-local goto (using longjmp(3)) such that destructors for automatic variables are not called. To avoid this problem, write the application so that you call tpreturn() or tpforward() from the service routine directly (instead of from any functions that are called from the service routine). In addition, one of the following should be true:

  • The service routine should not have any automatic variables with destructors (they should be declared and used in a function called by the service routine).

     

  • Automatic variables should be declared and used in a nested scope (contained within curly brackets {}) in such a way that the scope ends before calling the tpreturn() or tpforward() function.

你可能感兴趣的:(Tuxedo : Using C++'s Constructors and Destructors)