What's the performance penalty of weak_ptr?

后端 未结 3 661
耶瑟儿~
耶瑟儿~ 2021-01-03 18:53

I\'m currently designing a object structure for a game, and the most natural organization in my case became a tree. Being a great fan of smart pointers I use shared_pt

3条回答
  •  太阳男子
    2021-01-03 19:54

    For my own project, I was able to improve performance dramatically by adding #define BOOST_DISABLE_THREADS before any boost includes. This avoids the spinlock/mutex overhead of weak_ptr::lock which in my project was a major bottleneck. As the project is not multithreaded wrt boost, I could do this.

提交回复
热议问题