Index: src/libchcore/TBufferList.cpp =================================================================== diff -u -r6c41e7b3cf7711c6f5027c0c0154013f50f08e7b -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TBufferList.cpp (.../TBufferList.cpp) (revision 6c41e7b3cf7711c6f5027c0c0154013f50f08e7b) +++ src/libchcore/TBufferList.cpp (.../TBufferList.cpp) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -22,7 +22,8 @@ namespace chcore { - TBufferList::TBufferList() + TBufferList::TBufferList() : + m_eventAllBuffersAccountedFor(true, true) { } @@ -32,6 +33,7 @@ throw TCoreException(eErr_InvalidArgument, L"pBuffer", LOCATION); m_listBuffers.push_front(pBuffer); + UpdateEvent(); m_notifier(true); } @@ -43,6 +45,8 @@ TOverlappedDataBuffer* pBuffer = m_listBuffers.front(); m_listBuffers.pop_front(); + UpdateEvent(); + m_notifier(false); return pBuffer; @@ -54,7 +58,10 @@ m_listBuffers.clear(); if (bRemoved) + { + UpdateEvent(); m_notifier(false); + } } size_t TBufferList::GetCount() const @@ -71,4 +78,9 @@ { return m_notifier; } + + void TBufferList::UpdateEvent() + { + m_eventAllBuffersAccountedFor.SetEvent(m_listBuffers.size() == m_stExpectedBuffers); + } } Index: src/libchcore/TBufferList.h =================================================================== diff -u -r6c41e7b3cf7711c6f5027c0c0154013f50f08e7b -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TBufferList.h (.../TBufferList.h) (revision 6c41e7b3cf7711c6f5027c0c0154013f50f08e7b) +++ src/libchcore/TBufferList.h (.../TBufferList.h) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -20,6 +20,7 @@ #define __TBUFFERLIST_H__ #include +#include "TEvent.h" namespace chcore { @@ -38,11 +39,20 @@ size_t GetCount() const; bool IsEmpty() const; + void SetExpectedBuffers(size_t stExpectedBuffers) { m_stExpectedBuffers = stExpectedBuffers; } + HANDLE GetAllBuffersAccountedForEvent() const { return m_eventAllBuffersAccountedFor.Handle(); } + boost::signals2::signal& GetNotifier(); private: + void UpdateEvent(); + + private: + size_t m_stExpectedBuffers = 0; // count of buffers there should be in m_listBuffers when no buffer is in use std::list m_listBuffers; + boost::signals2::signal m_notifier; + TEvent m_eventAllBuffersAccountedFor; }; using TBufferListPtr = std::shared_ptr; Index: src/libchcore/TOverlappedMemoryPool.cpp =================================================================== diff -u -r6c41e7b3cf7711c6f5027c0c0154013f50f08e7b -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TOverlappedMemoryPool.cpp (.../TOverlappedMemoryPool.cpp) (revision 6c41e7b3cf7711c6f5027c0c0154013f50f08e7b) +++ src/libchcore/TOverlappedMemoryPool.cpp (.../TOverlappedMemoryPool.cpp) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -54,6 +54,7 @@ // buffer sizes increased - clear current buffers and proceed with creating new ones m_listAllBuffers.clear(); m_spQueueBuffers->Clear(); + m_spQueueBuffers->SetExpectedBuffers(0); } else if (stCount == m_listAllBuffers.size()) return; // nothing really changed @@ -72,6 +73,7 @@ m_spQueueBuffers->Push(upElement.get()); } + m_spQueueBuffers->SetExpectedBuffers(m_listAllBuffers.size()); return; } @@ -82,6 +84,8 @@ m_spQueueBuffers->Push(upBuffer.get()); m_listAllBuffers.push_back(std::move(upBuffer)); } + + m_spQueueBuffers->SetExpectedBuffers(m_listAllBuffers.size()); } size_t TOverlappedMemoryPool::GetTotalBufferCount() const Index: src/libchcore/TOverlappedReader.cpp =================================================================== diff -u -rc4cbf6cd567821f9a981586ab5d8294a26f873be -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TOverlappedReader.cpp (.../TOverlappedReader.cpp) (revision c4cbf6cd567821f9a981586ab5d8294a26f873be) +++ src/libchcore/TOverlappedReader.cpp (.../TOverlappedReader.cpp) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -27,9 +27,12 @@ TOverlappedReader::TOverlappedReader(const logger::TLogFileDataPtr& spLogFileData, const TBufferListPtr& spEmptyBuffers, unsigned long long ullFilePos, DWORD dwChunkSize) : m_spLog(logger::MakeLogger(spLogFileData, L"DataBuffer")), - m_tEmptyBuffers(spEmptyBuffers, ullFilePos, dwChunkSize), + m_spEmptyBuffers(spEmptyBuffers), + m_tInputBuffers(spEmptyBuffers, ullFilePos, dwChunkSize), m_spFullBuffers(std::make_shared(ullFilePos)) { + if(!spLogFileData) + throw TCoreException(eErr_InvalidArgument, L"spLogFileData is NULL", LOCATION); if(!spEmptyBuffers) throw TCoreException(eErr_InvalidArgument, L"spMemoryPool", LOCATION); if(dwChunkSize == 0) @@ -42,31 +45,45 @@ TOverlappedDataBuffer* TOverlappedReader::GetEmptyBuffer() { - return m_tEmptyBuffers.Pop(); + if(m_bReleaseMode) + return nullptr; + + return m_tInputBuffers.Pop(); } void TOverlappedReader::AddEmptyBuffer(TOverlappedDataBuffer* pBuffer, bool bKeepPosition) { if(!pBuffer) throw TCoreException(eErr_InvalidPointer, L"pBuffer", LOCATION); - LOG_TRACE(m_spLog) << L"Releasing empty buffer; buffer-order: " << pBuffer->GetFilePosition(); - - m_tEmptyBuffers.Push(pBuffer, bKeepPosition); + if(m_bReleaseMode) + m_tInputBuffers.Push(pBuffer, false); + else + { + LOG_TRACE(m_spLog) << L"Releasing empty buffer; buffer-order: " << pBuffer->GetFilePosition(); + m_tInputBuffers.Push(pBuffer, bKeepPosition); + } } void TOverlappedReader::AddFailedReadBuffer(TOverlappedDataBuffer* pBuffer) { if (!pBuffer) throw TCoreException(eErr_InvalidPointer, L"pBuffer", LOCATION); - LOG_TRACE(m_spLog) << L"Queuing buffer for re-read; buffer-order: " << pBuffer->GetFilePosition(); - - m_spFullBuffers->PushError(pBuffer, m_tEmptyBuffers); + if(m_bReleaseMode) + m_tInputBuffers.Push(pBuffer, false); + else + { + LOG_TRACE(m_spLog) << L"Queuing buffer for re-read; buffer-order: " << pBuffer->GetFilePosition(); + m_spFullBuffers->PushError(pBuffer, m_tInputBuffers); + } } TOverlappedDataBuffer* TOverlappedReader::GetFailedReadBuffer() { + if(m_bReleaseMode) + return nullptr; + return m_spFullBuffers->PopError(); } @@ -75,33 +92,36 @@ if (!pBuffer) throw TCoreException(eErr_InvalidPointer, L"pBuffer", LOCATION); - LOG_TRACE(m_spLog) << L"Queuing buffer as full; buffer-order: " << pBuffer->GetFilePosition() << - L", requested-data-size: " << pBuffer->GetRequestedDataSize() << - L", real-data-size: " << pBuffer->GetRealDataSize() << - L", file-position: " << pBuffer->GetFilePosition() << - L", error-code: " << pBuffer->GetErrorCode() << - L", status-code: " << pBuffer->GetStatusCode() << - L", is-last-part: " << pBuffer->IsLastPart(); + if(m_bReleaseMode) + { + m_tInputBuffers.Push(pBuffer, false); + } + else + { + LOG_TRACE(m_spLog) << L"Queuing buffer as full; buffer-order: " << pBuffer->GetFilePosition() << + L", requested-data-size: " << pBuffer->GetRequestedDataSize() << + L", real-data-size: " << pBuffer->GetRealDataSize() << + L", file-position: " << pBuffer->GetFilePosition() << + L", error-code: " << pBuffer->GetErrorCode() << + L", status-code: " << pBuffer->GetStatusCode() << + L", is-last-part: " << pBuffer->IsLastPart(); - if(pBuffer->IsLastPart()) - m_tEmptyBuffers.SetDataSourceFinished(pBuffer); + if(pBuffer->IsLastPart()) + m_tInputBuffers.SetDataSourceFinished(pBuffer); - m_spFullBuffers->Push(pBuffer); + m_spFullBuffers->Push(pBuffer); + } } TOrderedBufferQueuePtr TOverlappedReader::GetFinishedQueue() const { return m_spFullBuffers; } - size_t TOverlappedReader::GetBufferCount() const + void TOverlappedReader::ReleaseBuffers() { - return m_tEmptyBuffers.GetCount() + m_spFullBuffers->GetCount(); + m_bReleaseMode = true; + m_tInputBuffers.ReleaseBuffers(m_spEmptyBuffers); + m_spFullBuffers->ReleaseBuffers(m_spEmptyBuffers); } - - void TOverlappedReader::ReleaseBuffers(const TBufferListPtr& spBuffers) - { - m_tEmptyBuffers.ReleaseBuffers(spBuffers); - m_spFullBuffers->ReleaseBuffers(spBuffers); - } } Index: src/libchcore/TOverlappedReader.h =================================================================== diff -u -rc4cbf6cd567821f9a981586ab5d8294a26f873be -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TOverlappedReader.h (.../TOverlappedReader.h) (revision c4cbf6cd567821f9a981586ab5d8294a26f873be) +++ src/libchcore/TOverlappedReader.h (.../TOverlappedReader.h) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -51,22 +51,24 @@ TOrderedBufferQueuePtr GetFinishedQueue() const; // processing info - bool IsDataSourceFinished() const { return m_tEmptyBuffers.IsDataSourceFinished(); } + bool IsDataSourceFinished() const { return m_tInputBuffers.IsDataSourceFinished(); } // event access - HANDLE GetEventReadPossibleHandle() const { return m_tEmptyBuffers.GetHasBuffersEvent(); } + HANDLE GetEventReadPossibleHandle() const { return m_tInputBuffers.GetHasBuffersEvent(); } HANDLE GetEventReadFailedHandle() const { return m_spFullBuffers->GetHasErrorEvent(); } HANDLE GetEventReadFinishedHandle() const { return m_spFullBuffers->GetHasBuffersEvent(); } - size_t GetBufferCount() const; - void ReleaseBuffers(const TBufferListPtr& spBuffers); + void ReleaseBuffers(); private: logger::TLoggerPtr m_spLog; // queues - TReadBufferQueueWrapper m_tEmptyBuffers; + TBufferListPtr m_spEmptyBuffers; + TReadBufferQueueWrapper m_tInputBuffers; TOrderedBufferQueuePtr m_spFullBuffers; // buffers with data + + bool m_bReleaseMode = false; // when set, all incoming buffers will go to empty buffers }; } Index: src/libchcore/TOverlappedReaderWriter.cpp =================================================================== diff -u -r6c41e7b3cf7711c6f5027c0c0154013f50f08e7b -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TOverlappedReaderWriter.cpp (.../TOverlappedReaderWriter.cpp) (revision 6c41e7b3cf7711c6f5027c0c0154013f50f08e7b) +++ src/libchcore/TOverlappedReaderWriter.cpp (.../TOverlappedReaderWriter.cpp) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -31,7 +31,7 @@ m_spLog(logger::MakeLogger(spLogFileData, L"DataBuffer")), m_spMemoryPool(spMemoryPool), m_tReader(spLogFileData, spMemoryPool->GetBufferList(), ullFilePos, dwChunkSize), - m_tWriter(spLogFileData, m_tReader.GetFinishedQueue(), ullFilePos), + m_tWriter(spLogFileData, m_tReader.GetFinishedQueue(), ullFilePos, spMemoryPool->GetBufferList()), m_eventAllBuffersAccountedFor(true, true) { if(!spMemoryPool) @@ -46,10 +46,7 @@ { TOverlappedDataBuffer* pBuffer = m_tReader.GetEmptyBuffer(); if(pBuffer) - { pBuffer->SetParam(this); - UpdateAllBuffersAccountedFor(); - } return pBuffer; } @@ -68,17 +65,11 @@ L", is-last-part: " << pBuffer->IsLastPart(); m_tReader.AddEmptyBuffer(pBuffer, bKeepPosition); - UpdateAllBuffersAccountedFor(); } TOverlappedDataBuffer* TOverlappedReaderWriter::GetFailedReadBuffer() { - TOverlappedDataBuffer* pBuffer = m_tReader.GetFailedReadBuffer(); - - if(pBuffer) - UpdateAllBuffersAccountedFor(); - - return pBuffer; + return m_tReader.GetFailedReadBuffer(); } void TOverlappedReaderWriter::AddFailedReadBuffer(TOverlappedDataBuffer* pBuffer) @@ -95,20 +86,15 @@ L", is-last-part: " << pBuffer->IsLastPart(); m_tReader.AddFailedReadBuffer(pBuffer); - UpdateAllBuffersAccountedFor(); } TOverlappedDataBuffer* TOverlappedReaderWriter::GetWriteBuffer() { TOverlappedDataBuffer* pBuffer = m_tWriter.GetWriteBuffer(); if(pBuffer) - { pBuffer->SetParam(this); - UpdateAllBuffersAccountedFor(); - } - return pBuffer; } @@ -125,17 +111,11 @@ L", status-code: " << pBuffer->GetStatusCode() << L", is-last-part: " << pBuffer->IsLastPart(); m_tReader.AddFullBuffer(pBuffer); - - UpdateAllBuffersAccountedFor(); } TOverlappedDataBuffer* TOverlappedReaderWriter::GetFailedWriteBuffer() { - TOverlappedDataBuffer* pBuffer = m_tWriter.GetFailedWriteBuffer(); - if(pBuffer) - UpdateAllBuffersAccountedFor(); - - return pBuffer; + return m_tWriter.GetFailedWriteBuffer(); } void TOverlappedReaderWriter::AddFailedWriteBuffer(TOverlappedDataBuffer* pBuffer) @@ -154,21 +134,13 @@ // overwrite error code (to avoid treating the buffer as failed read) pBuffer->SetErrorCode(ERROR_SUCCESS); m_tWriter.AddFailedWriteBuffer(pBuffer); - - UpdateAllBuffersAccountedFor(); } TOverlappedDataBuffer* TOverlappedReaderWriter::GetFinishedWriteBuffer() { - TOverlappedDataBuffer* pBuffer = m_tWriter.GetFinishedBuffer(); - - if(pBuffer) - UpdateAllBuffersAccountedFor(); - - return pBuffer; + return m_tWriter.GetFinishedBuffer(); } - void TOverlappedReaderWriter::AddFinishedWriteBuffer(TOverlappedDataBuffer* pBuffer) { if (!pBuffer) @@ -183,8 +155,6 @@ L", is-last-part: " << pBuffer->IsLastPart(); m_tWriter.AddFinishedBuffer(pBuffer); - - UpdateAllBuffersAccountedFor(); } void TOverlappedReaderWriter::MarkFinishedBufferAsComplete(TOverlappedDataBuffer* pBuffer) @@ -203,19 +173,13 @@ m_tWriter.MarkAsFinalized(pBuffer); } - void TOverlappedReaderWriter::UpdateAllBuffersAccountedFor() - { - size_t stCurrentBuffers = m_spMemoryPool->GetAvailableBufferCount() + m_tReader.GetBufferCount() + m_tWriter.GetBufferCount(); - if (stCurrentBuffers == m_spMemoryPool->GetTotalBufferCount()) - m_eventAllBuffersAccountedFor.SetEvent(); - else - m_eventAllBuffersAccountedFor.ResetEvent(); - } - void TOverlappedReaderWriter::WaitForMissingBuffersAndResetState(HANDLE hKillEvent) { + m_tReader.ReleaseBuffers(); + m_tWriter.ReleaseBuffers(); + enum { eKillThread = 0, eAllBuffersReturned, eHandleCount }; - std::array arrHandles = { hKillEvent, m_eventAllBuffersAccountedFor.Handle() }; + std::array arrHandles = { hKillEvent, m_spMemoryPool->GetBufferList()->GetAllBuffersAccountedForEvent() }; bool bExit = false; while (!bExit) @@ -235,8 +199,5 @@ break; } } - - m_tReader.ReleaseBuffers(m_spMemoryPool->GetBufferList()); - m_tWriter.ReleaseBuffers(m_spMemoryPool->GetBufferList()); } } Index: src/libchcore/TOverlappedReaderWriter.h =================================================================== diff -u -r6c41e7b3cf7711c6f5027c0c0154013f50f08e7b -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TOverlappedReaderWriter.h (.../TOverlappedReaderWriter.h) (revision 6c41e7b3cf7711c6f5027c0c0154013f50f08e7b) +++ src/libchcore/TOverlappedReaderWriter.h (.../TOverlappedReaderWriter.h) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -77,9 +77,6 @@ void WaitForMissingBuffersAndResetState(HANDLE hKillEvent); private: - void UpdateAllBuffersAccountedFor(); - - private: logger::TLoggerPtr m_spLog; TOverlappedMemoryPoolPtr m_spMemoryPool; Index: src/libchcore/TOverlappedWriter.cpp =================================================================== diff -u -r6c41e7b3cf7711c6f5027c0c0154013f50f08e7b -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TOverlappedWriter.cpp (.../TOverlappedWriter.cpp) (revision 6c41e7b3cf7711c6f5027c0c0154013f50f08e7b) +++ src/libchcore/TOverlappedWriter.cpp (.../TOverlappedWriter.cpp) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -25,13 +25,19 @@ namespace chcore { TOverlappedWriter::TOverlappedWriter(const logger::TLogFileDataPtr& spLogFileData, const TOrderedBufferQueuePtr& spBuffersToWrite, - unsigned long long ullFilePos) : + unsigned long long ullFilePos, const TBufferListPtr& spEmptyBuffers) : m_spLog(logger::MakeLogger(spLogFileData, L"DataBuffer")), m_tBuffersToWrite(spBuffersToWrite), - m_tFinishedBuffers(ullFilePos) + m_tFinishedBuffers(ullFilePos), + m_spEmptyBuffers(spEmptyBuffers) { + if(!spLogFileData) + throw TCoreException(eErr_InvalidArgument, L"spLogFileData is NULL", LOCATION); if(!spBuffersToWrite) - throw TCoreException(eErr_InvalidArgument, L"spBuffersToWrite", LOCATION); + throw TCoreException(eErr_InvalidArgument, L"spBuffersToWrite is NULL", LOCATION); + if(!spEmptyBuffers) + throw TCoreException(eErr_InvalidArgument, L"spEmptyBuffers is NULL", LOCATION); + } TOverlappedWriter::~TOverlappedWriter() @@ -40,6 +46,9 @@ TOverlappedDataBuffer* TOverlappedWriter::GetWriteBuffer() { + if(m_bReleaseMode) + return nullptr; + return m_tBuffersToWrite.Pop(); } @@ -48,27 +57,38 @@ if(!pBuffer) throw TCoreException(eErr_InvalidPointer, L"pBuffer", LOCATION); - LOG_TRACE(m_spLog) << L"Queuing buffer as full (failed); buffer-order: " << pBuffer->GetFilePosition() << - L", requested-data-size: " << pBuffer->GetRequestedDataSize() << - L", real-data-size: " << pBuffer->GetRealDataSize() << - L", file-position: " << pBuffer->GetFilePosition() << - L", error-code: " << pBuffer->GetErrorCode() << - L", status-code: " << pBuffer->GetStatusCode() << - L", is-last-part: " << pBuffer->IsLastPart(); + if(m_bReleaseMode) + m_spEmptyBuffers->Push(pBuffer); + else + { + LOG_TRACE(m_spLog) << L"Queuing buffer as full (failed); buffer-order: " << pBuffer->GetFilePosition() << + L", requested-data-size: " << pBuffer->GetRequestedDataSize() << + L", real-data-size: " << pBuffer->GetRealDataSize() << + L", file-position: " << pBuffer->GetFilePosition() << + L", error-code: " << pBuffer->GetErrorCode() << + L", status-code: " << pBuffer->GetStatusCode() << + L", is-last-part: " << pBuffer->IsLastPart(); - // overwrite error code (to avoid treating the buffer as failed read) - pBuffer->SetErrorCode(ERROR_SUCCESS); + // overwrite error code (to avoid treating the buffer as failed read) + pBuffer->SetErrorCode(ERROR_SUCCESS); - m_tFinishedBuffers.PushError(pBuffer, m_tBuffersToWrite); + m_tFinishedBuffers.PushError(pBuffer, m_tBuffersToWrite); + } } TOverlappedDataBuffer* TOverlappedWriter::GetFailedWriteBuffer() { + if(m_bReleaseMode) + return nullptr; + return m_tFinishedBuffers.PopError(); } TOverlappedDataBuffer* TOverlappedWriter::GetFinishedBuffer() { + if(m_bReleaseMode) + return nullptr; + TOverlappedDataBuffer* pBuffer = m_tFinishedBuffers.Pop(); if (pBuffer && pBuffer->IsLastPart()) @@ -83,9 +103,12 @@ void TOverlappedWriter::MarkAsFinalized(TOverlappedDataBuffer* pBuffer) { - if (!pBuffer) + if(!pBuffer) throw TCoreException(eErr_InvalidPointer, L"pBuffer", LOCATION); + if(m_bReleaseMode) + return; + if (pBuffer != m_pLastPartBuffer) throw TCoreException(eErr_InvalidArgument, L"Trying to mark different buffer as finalized", LOCATION); @@ -97,25 +120,27 @@ if (!pBuffer) throw TCoreException(eErr_InvalidPointer, L"pBuffer", LOCATION); - LOG_TRACE(m_spLog) << L"Queuing buffer as finished; buffer-order: " << pBuffer->GetFilePosition() << - L", requested-data-size: " << pBuffer->GetRequestedDataSize() << - L", real-data-size: " << pBuffer->GetRealDataSize() << - L", file-position: " << pBuffer->GetFilePosition() << - L", error-code: " << pBuffer->GetErrorCode() << - L", status-code: " << pBuffer->GetStatusCode() << - L", is-last-part: " << pBuffer->IsLastPart(); + if(m_bReleaseMode) + m_spEmptyBuffers->Push(pBuffer); + else + { + LOG_TRACE(m_spLog) << L"Queuing buffer as finished; buffer-order: " << pBuffer->GetFilePosition() << + L", requested-data-size: " << pBuffer->GetRequestedDataSize() << + L", real-data-size: " << pBuffer->GetRealDataSize() << + L", file-position: " << pBuffer->GetFilePosition() << + L", error-code: " << pBuffer->GetErrorCode() << + L", status-code: " << pBuffer->GetStatusCode() << + L", is-last-part: " << pBuffer->IsLastPart(); - m_tFinishedBuffers.Push(pBuffer); + m_tFinishedBuffers.Push(pBuffer); + } } - size_t TOverlappedWriter::GetBufferCount() const + void TOverlappedWriter::ReleaseBuffers() { - return m_tFinishedBuffers.GetCount(); + m_bReleaseMode = true; + m_pLastPartBuffer = nullptr; + m_tBuffersToWrite.ReleaseBuffers(m_spEmptyBuffers); + m_tFinishedBuffers.ReleaseBuffers(m_spEmptyBuffers); } - - void TOverlappedWriter::ReleaseBuffers(const TBufferListPtr& spList) - { - m_tBuffersToWrite.ReleaseBuffers(spList); - m_tFinishedBuffers.ReleaseBuffers(spList); - } } Index: src/libchcore/TOverlappedWriter.h =================================================================== diff -u -r6c41e7b3cf7711c6f5027c0c0154013f50f08e7b -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/TOverlappedWriter.h (.../TOverlappedWriter.h) (revision 6c41e7b3cf7711c6f5027c0c0154013f50f08e7b) +++ src/libchcore/TOverlappedWriter.h (.../TOverlappedWriter.h) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -34,7 +34,7 @@ public: explicit TOverlappedWriter(const logger::TLogFileDataPtr& spLogFileData, const TOrderedBufferQueuePtr& spBuffersToWrite, - unsigned long long ullFilePos); + unsigned long long ullFilePos, const TBufferListPtr& spEmptyBuffers); TOverlappedWriter(const TOverlappedWriter&) = delete; ~TOverlappedWriter(); @@ -57,16 +57,19 @@ HANDLE GetEventWriteFailedHandle() const { return m_tFinishedBuffers.GetHasErrorEvent(); } HANDLE GetEventWriteFinishedHandle() const { return m_tFinishedBuffers.GetHasBuffersEvent(); } - size_t GetBufferCount() const; - void ReleaseBuffers(const TBufferListPtr& spList); + void ReleaseBuffers(); private: logger::TLoggerPtr m_spLog; + TBufferListPtr m_spEmptyBuffers; + TWriteBufferQueueWrapper m_tBuffersToWrite; TOrderedBufferQueue m_tFinishedBuffers; TOverlappedDataBuffer* m_pLastPartBuffer = nullptr; + + bool m_bReleaseMode = false; }; } Index: src/libchcore/Tests/TOverlappedWriterTests.cpp =================================================================== diff -u -rda7737de7046ba0ecd255240fb36b4a46584ebf2 -r593ca68706f3a3c7c2a3820b02a56fc24d5bea11 --- src/libchcore/Tests/TOverlappedWriterTests.cpp (.../TOverlappedWriterTests.cpp) (revision da7737de7046ba0ecd255240fb36b4a46584ebf2) +++ src/libchcore/Tests/TOverlappedWriterTests.cpp (.../TOverlappedWriterTests.cpp) (revision 593ca68706f3a3c7c2a3820b02a56fc24d5bea11) @@ -9,6 +9,7 @@ { logger::TLogFileDataPtr spLogData(std::make_shared()); TOrderedBufferQueuePtr spQueue(std::make_shared(0)); + TBufferListPtr spEmptyBuffers(std::make_shared()); - TOverlappedWriter writer(spLogData, spQueue, 0); + TOverlappedWriter writer(spLogData, spQueue, 0, spEmptyBuffers); }