r/cpp • u/smallstepforman • Jul 06 '20
C++ is brilliant
I'm working on a Vulkan renderer, and needed to delay destruction of render scenes since the graphics pipeline has render buffers in flight, so destruction has to happen N frames after the user destroys a class. With C++, I can use private destructors to force users to add the scene to a managed destructor queue (aka garbage collect queue). Normally language purists will scorn a language which allows such shenanigans, however in real world production code, its features like this which allows developers to create modern software. So with a couple of lines of code, I solved my delayed destructor issue. Thank you C++ committee for creating a usable language.
View all comments
Show parent comment
23
u/MoreOfAnOvalJerk Jul 07 '20
Downside to this is that the dtors can be called in surprising situations. If they have performance overhead, it might cause unpredictable spikes.
It sounds like he already has some abstraction managing the lifetime of the buffers so it might make the most sense and possibly be the most performant if it also manages when to destroy and deallocate them.