Fix destruction order issue in SourceImpl. (#89)

The Frame destructor calls back into SourceImpl, locking m_poolMutex, so
it's necessary to destroy m_frame before m_poolMutex.  Reverse destruction
order to member definition order is guaranteed by the C++ standard.
This commit is contained in:
Peter Johnson
2017-08-14 22:27:28 -07:00
committed by GitHub
parent 7ef56de3f2
commit 9d45088127

View File

@@ -202,10 +202,6 @@ class SourceImpl {
std::mutex m_frameMutex;
std::condition_variable m_frameCv;
// Most recent frame (returned to callers of GetNextFrame)
// Access protected by m_frameMutex.
Frame m_frame;
bool m_destroyFrames{false};
// Pool of frames/images to reduce malloc traffic.
@@ -214,6 +210,12 @@ class SourceImpl {
std::vector<std::unique_ptr<Image>> m_imagesAvail;
std::atomic_bool m_connected{false};
// Most recent frame (returned to callers of GetNextFrame)
// Access protected by m_frameMutex.
// MUST be located below m_poolMutex as the Frame destructor calls back
// into SourceImpl::ReleaseImage, which locks m_poolMutex.
Frame m_frame;
};
} // namespace cs