boostorg / lockfree

Boost.Lockfree
126 stars 86 forks source link

differering destructor behavior with compile-time size #66

Closed PatrickAMoran closed 3 years ago

PatrickAMoran commented 3 years ago

I noticed something I found surprising - a boost::lockfree:spsc_queue behaves differently on destruction if you give it a compile-time size vs giving it a runtime size. When you have a runtime-sized queue, then any elements still in the queue are destructed when the queue destructs (which is how I usually expect containers to behave). That is handled here. But compile_time_sized_ringbuffer doesn't have a destructor declared, and it's storage is just a boost::aligned_storage, so it won't destruct any stored objects either.

My assumption is that this is not intentional, and that we expect the remaining elements of the queue to be destructed when destroying a compile-time-sized spsc_queue?

timblechmann commented 3 years ago

thanks for flagging this. pushed a fix