template<typename P>
class maxon::ThreadLocalDestructiblePointer< P >
Thread local pointer with notification upon destruction. This is similar to ThreadLocalPointer but when a thread exits or the object is destructed a per-thread notification is invoked which can be used to free resources.
- Note
- Thread local pointers are a scarce resource. Only a limited number of them can be allocated: On Windows about 100 (there are less FLS than TLS entries) and on OS X about 500. You should only use them if they are the last and only resort to solve a problem. Furthermore for performance reasons it is best to avoid thread local variables at all and instead use some sort of local context (for a group's jobs or with ParallelFor).
-
A thread local pointer is bound to a OS thread and the pointer is stored for the lifetime of the thread. If you create and use thread local variables in a module you must ensure that they are destructed properly before the module is unloaded.
-
On Windows this is 50 % slower than ThreadLocalPointer. Furthermore the code must not use the (deprecated) fiber calls (ConvertThreadToFiber, CreateFiber etc.).