Index: src/libchcore/TBufferList.h =================================================================== diff -u -N -rd99302fce795dbb5139659016a5da7948f141fb4 -rcb1a7688ad1ac1081a219c170754776e986ccc8c --- src/libchcore/TBufferList.h (.../TBufferList.h) (revision d99302fce795dbb5139659016a5da7948f141fb4) +++ src/libchcore/TBufferList.h (.../TBufferList.h) (revision cb1a7688ad1ac1081a219c170754776e986ccc8c) @@ -42,20 +42,18 @@ if(!pBuffer) throw TCoreException(eErr_InvalidArgument, L"pBuffer", LOCATION); - { - boost::unique_lock lock(m_mutex); + boost::unique_lock lock(m_mutex); - m_queueBuffers.push_front(pBuffer); - m_spCount->Increase(); - } + m_queueBuffers.push_front(pBuffer); + m_spCount->Increase(); } TOverlappedDataBuffer* Pop() { TOverlappedDataBuffer* pBuffer = nullptr; { - boost::unique_lock lock(m_mutex); + boost::unique_lock lock(m_mutex); if(m_queueBuffers.empty()) return nullptr; @@ -70,35 +68,33 @@ void Clear() { - bool bRemoved = false; - { - boost::unique_lock lock(m_mutex); + boost::unique_lock lock(m_mutex); - bRemoved = !m_queueBuffers.empty(); - m_queueBuffers.clear(); - m_spCount->SetValue(0); - } + m_queueBuffers.clear(); + m_spCount->SetValue(0); } size_t GetCount() const { + boost::unique_lock lock(m_mutex); return m_spCount->GetValue(); } bool IsEmpty() const { + boost::unique_lock lock(m_mutex); return m_spCount->GetValue() == 0; } void SetExpectedBuffersCount(size_t stExpectedBuffers) // thread-unsafe by design { - boost::unique_lock lock(m_mutex); + boost::unique_lock lock(m_mutex); m_stExpectedBuffers = stExpectedBuffers; } bool AreAllBuffersAccountedFor() const { - boost::shared_lock lock(m_mutex); + boost::unique_lock lock(m_mutex); return m_stExpectedBuffers == m_spCount->GetValue(); } @@ -108,7 +104,7 @@ } private: - mutable boost::shared_mutex m_mutex; + mutable boost::mutex m_mutex; TSharedCountMTPtr m_spCount; size_t m_stExpectedBuffers = 0; // count of buffers there should be in m_queueBuffers when no buffer is in use