Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::ThreadLocalPtr destruction  (Read 893 times)

0 Members and 1 Guest are viewing this topic.

Jugger

  • Newbie
  • *
  • Posts: 2
    • View Profile
sf::ThreadLocalPtr destruction
« 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?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6232
  • Thor Developer
    • View Profile
    • Bromeon
Re: sf::ThreadLocalPtr destruction
« Reply #1 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: first SFML book

Jugger

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: sf::ThreadLocalPtr destruction
« Reply #2 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.