SFML community forums

Help => System => Topic started by: Jugger on February 03, 2013, 12:27:23 pm

Title: sf::ThreadLocalPtr destruction
Post by: Jugger on February 03, 2013, 12:27:23 pm
Hi there.

I was playing around with sf::ThreadLocalPtr and it appears that its destructor doesn't call destructors of the stored objects. This causes leaks when the sf::ThreadLocalPtr is destroyed. I was thinking about manually destroying all the objects stored in the sf::ThreadLocalPtr prior to its destruction, but I have no idea how to do something like that or whether it's actually possible.

Is there any way how to prevent these leaks or do I have to use boost::thread_specific_ptr for this functionality?
Title: Re: sf::ThreadLocalPtr destruction
Post by: Nexus on February 03, 2013, 12:36:27 pm
In C++11, there is the thread_local storage class specifier. However I don't know how widely it is supported yet.
Title: Re: sf::ThreadLocalPtr destruction
Post by: Jugger on February 03, 2013, 02:06:28 pm
Thanks for the reply, but using thread_local won't work for me, because my compiler doesn't support it yet. I also like to keep my code portable so I try not to rely on C++11 features too much yet.

I tried using boost::thread_specific_ptr and it does exactly what I want, but I'd prefer using SFML implementation of thread local storage if possible to minimize dependencies.