Manually takes care of the lifetime of the per-thread temporary_stack.
The constructor will create it, if not already done, and the destructor will destroy it, if not already done.
- Note
- If there are multiple objects in a thread, this will lead to unnecessary construction and destruction of the stack. It is thus adviced to create one object on the top-level function of the thread, e.g. in
main()
.
-
If
FOONATHAN_MEMORY_TEMPORARY_STACK_MODE == 2
, it is not necessary to use this class, the nifty counter will clean everything upon program termination. But it can still be used as an optimization if you have a thread that is terminated long before program exit. The automatic clean up will only occur much later.
-
If
FOONATHAN_MEMORY_TEMPORARY_STACK_MODE == 0
, the use of this class has no effect, because the per-thread stack is disabled.