Index: src/libchcore/TOrderedBufferQueue.cpp =================================================================== diff -u -rb051cbac8dac8c448507aa7c64753af9cf793af5 -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/TOrderedBufferQueue.cpp (.../TOrderedBufferQueue.cpp) (revision b051cbac8dac8c448507aa7c64753af9cf793af5) +++ src/libchcore/TOrderedBufferQueue.cpp (.../TOrderedBufferQueue.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -25,14 +25,22 @@ namespace chcore { - TOrderedBufferQueue::TOrderedBufferQueue(unsigned long long ullExpectedPosition) : + TOrderedBufferQueue::TOrderedBufferQueue(const TBufferListPtr& spEmptyBuffers, unsigned long long ullExpectedPosition) : + m_spEmptyBuffers(spEmptyBuffers), m_eventHasBuffers(true, false), m_eventHasError(true, false), m_eventHasReadingFinished(true, false), m_ullExpectedBufferPosition(ullExpectedPosition) { + if(!spEmptyBuffers) + throw TCoreException(eErr_InvalidArgument, L"spEmptyBuffers is NULL", LOCATION); } + TOrderedBufferQueue::~TOrderedBufferQueue() + { + ClearBuffers(); + } + void TOrderedBufferQueue::Push(TOverlappedDataBuffer* pBuffer) { if(!pBuffer) @@ -146,22 +154,19 @@ return m_eventHasReadingFinished.Handle(); } - void TOrderedBufferQueue::ClearBuffers(const TBufferListPtr& spBuffers) + void TOrderedBufferQueue::ClearBuffers() { - if(!spBuffers) - throw TCoreException(eErr_InvalidArgument, L"spBuffers is NULL", LOCATION); - boost::unique_lock lock(m_mutex); for(TOverlappedDataBuffer* pBuffer : m_setBuffers) { - spBuffers->Push(pBuffer); + m_spEmptyBuffers->Push(pBuffer); } m_setBuffers.clear(); if(m_pFirstErrorBuffer) { - spBuffers->Push(m_pFirstErrorBuffer); + m_spEmptyBuffers->Push(m_pFirstErrorBuffer); m_pFirstErrorBuffer = nullptr; m_ullErrorPosition = NoPosition; } Index: src/libchcore/TOrderedBufferQueue.h =================================================================== diff -u -rc719644bb4360fcf7ccf6f1139bcae852bd6effd -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/TOrderedBufferQueue.h (.../TOrderedBufferQueue.h) (revision c719644bb4360fcf7ccf6f1139bcae852bd6effd) +++ src/libchcore/TOrderedBufferQueue.h (.../TOrderedBufferQueue.h) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -34,7 +34,8 @@ static const unsigned long long NoPosition = 0xffffffffffffffff; public: - explicit TOrderedBufferQueue(unsigned long long ullExpectedPosition); + explicit TOrderedBufferQueue(const TBufferListPtr& spEmptyBuffers, unsigned long long ullExpectedPosition); + ~TOrderedBufferQueue(); void Push(TOverlappedDataBuffer* pBuffer); @@ -54,7 +55,7 @@ HANDLE GetHasErrorEvent() const; HANDLE GetHasReadingFinished() const; - void ClearBuffers(const TBufferListPtr& spBuffers); + void ClearBuffers(); boost::signals2::signal& GetNotifier(); @@ -71,6 +72,8 @@ using BufferCollection = std::set; BufferCollection m_setBuffers; + TBufferListPtr m_spEmptyBuffers; + mutable boost::shared_mutex m_mutex; TOverlappedDataBuffer* m_pFirstErrorBuffer = nullptr; Index: src/libchcore/TOverlappedReader.cpp =================================================================== diff -u -rc719644bb4360fcf7ccf6f1139bcae852bd6effd -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/TOverlappedReader.cpp (.../TOverlappedReader.cpp) (revision c719644bb4360fcf7ccf6f1139bcae852bd6effd) +++ src/libchcore/TOverlappedReader.cpp (.../TOverlappedReader.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -29,7 +29,7 @@ DWORD dwChunkSize) : m_spLog(logger::MakeLogger(spLogFileData, L"DataBuffer")), m_tInputBuffers(spEmptyBuffers, spDataRange ? spDataRange->GetResumePosition() : 0, dwChunkSize), - m_spFullBuffers(std::make_shared(spDataRange ? spDataRange->GetResumePosition() : 0)) + m_spFullBuffers(std::make_shared(spEmptyBuffers, spDataRange ? spDataRange->GetResumePosition() : 0)) { if(!spLogFileData) throw TCoreException(eErr_InvalidArgument, L"spLogFileData is NULL", LOCATION); Index: src/libchcore/TOverlappedReaderFB.cpp =================================================================== diff -u -rc175b6c9d5be6ee6ee0eae90abb167b9eaf2abc3 -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/TOverlappedReaderFB.cpp (.../TOverlappedReaderFB.cpp) (revision c175b6c9d5be6ee6ee0eae90abb167b9eaf2abc3) +++ src/libchcore/TOverlappedReaderFB.cpp (.../TOverlappedReaderFB.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -72,7 +72,9 @@ TSubTaskBase::ESubOperationResult TOverlappedReaderFB::StopThreaded() { - WaitForSingleObjectEx(m_eventProcessingFinished.Handle(), INFINITE, FALSE); + DWORD dwResult = WaitForSingleObjectEx(m_eventProcessingFinished.Handle(), INFINITE, FALSE); + _ASSERTE(dwResult == WAIT_OBJECT_0); dwResult; + return m_eThreadResult; } @@ -155,18 +157,24 @@ void TOverlappedReaderFB::WaitForOnTheFlyBuffers() { - DWORD dwResult = WaitForSingleObjectEx(m_counterOnTheFly.GetEventHandle(), INFINITE, TRUE); - switch(dwResult) + bool bStop = false; + do { - case STATUS_USER_APC: - break; + DWORD dwResult = WaitForSingleObjectEx(m_counterOnTheFly.GetEventHandle(), INFINITE, TRUE); + switch(dwResult) + { + case STATUS_USER_APC: + break; - case WAIT_OBJECT_0: - return; + case WAIT_OBJECT_0: + bStop = true; + break; - default: - throw TCoreException(eErr_UnhandledCase, L"Unknown result from async waiting function", LOCATION); + default: + throw TCoreException(eErr_UnhandledCase, L"Unknown result from async waiting function", LOCATION); + } } + while(!bStop); } void TOverlappedReaderFB::ClearQueues() Index: src/libchcore/TOverlappedReaderWriterFB.cpp =================================================================== diff -u -rc719644bb4360fcf7ccf6f1139bcae852bd6effd -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/TOverlappedReaderWriterFB.cpp (.../TOverlappedReaderWriterFB.cpp) (revision c719644bb4360fcf7ccf6f1139bcae852bd6effd) +++ src/libchcore/TOverlappedReaderWriterFB.cpp (.../TOverlappedReaderWriterFB.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -79,15 +79,14 @@ // - read possible - lowest priority - if we don't have anything to write or finalize , then read another part of source data enum { - eReadingFinished, eWritingFinished, eKillThread + eReadingFinished, eWritingFinished }; TEvent unsignaledEvent(true, false); std::vector vHandles = { m_spReader->GetEventProcessingFinishedHandle(), - m_spWriter->GetEventProcessingFinishedHandle(), - m_rThreadController.GetKillThreadHandle() // kill is last to allow reader and writer to exit first + m_spWriter->GetEventProcessingFinishedHandle() }; bool bStopProcessing = false; @@ -99,11 +98,6 @@ case STATUS_USER_APC: break; - case WAIT_OBJECT_0 + eKillThread: - eResult = TSubTaskBase::eSubResult_KillRequest; - bStopProcessing = true; - break; - case WAIT_OBJECT_0 + eWritingFinished: eResult = m_spWriter->StopThreaded(); vHandles[eWritingFinished] = unsignaledEvent.Handle(); @@ -121,9 +115,17 @@ } } + // ensure both reader and writer are correctly stopped + m_spReader->StopThreaded(); + m_spWriter->StopThreaded(); + + // get rid of reader and writer - mostly to release the buffers being used + m_spReader.reset(); + m_spWriter.reset(); + // ensure that no buffer was lost in the process if(!m_spMemoryPool->GetBufferList()->AreAllBuffersAccountedFor()) - throw TCoreException(eErr_InternalProblem, L"", LOCATION); + throw TCoreException(eErr_InternalProblem, L"Some buffers were lost in action", LOCATION); return eResult; } Index: src/libchcore/TOverlappedWriter.cpp =================================================================== diff -u -rb051cbac8dac8c448507aa7c64753af9cf793af5 -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/TOverlappedWriter.cpp (.../TOverlappedWriter.cpp) (revision b051cbac8dac8c448507aa7c64753af9cf793af5) +++ src/libchcore/TOverlappedWriter.cpp (.../TOverlappedWriter.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -29,7 +29,7 @@ m_spLog(logger::MakeLogger(spLogFileData, L"DataBuffer")), m_spEmptyBuffers(spEmptyBuffers), m_tBuffersToWrite(spBuffersToWrite), - m_tFinishedBuffers(spRange != nullptr ? spRange->GetResumePosition() : 0) + m_tFinishedBuffers(spEmptyBuffers, spRange != nullptr ? spRange->GetResumePosition() : 0) { if(!spLogFileData) throw TCoreException(eErr_InvalidArgument, L"spLogFileData is NULL", LOCATION); @@ -163,7 +163,7 @@ void TOverlappedWriter::ClearBuffers() { m_tBuffersToWrite.ClearBuffers(m_spEmptyBuffers); - m_tFinishedBuffers.ClearBuffers(m_spEmptyBuffers); + m_tFinishedBuffers.ClearBuffers(); } void TOverlappedWriter::AddFinishedBuffer(TOverlappedDataBuffer* pBuffer) Index: src/libchcore/TOverlappedWriterFB.cpp =================================================================== diff -u -rc175b6c9d5be6ee6ee0eae90abb167b9eaf2abc3 -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/TOverlappedWriterFB.cpp (.../TOverlappedWriterFB.cpp) (revision c175b6c9d5be6ee6ee0eae90abb167b9eaf2abc3) +++ src/libchcore/TOverlappedWriterFB.cpp (.../TOverlappedWriterFB.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -355,23 +355,31 @@ void TOverlappedWriterFB::WaitForOnTheFlyBuffers() { - DWORD dwResult = WaitForSingleObjectEx(m_counterOnTheFly.GetEventHandle(), INFINITE, TRUE); - switch(dwResult) + bool bStop = false; + do { - case STATUS_USER_APC: - break; + DWORD dwResult = WaitForSingleObjectEx(m_counterOnTheFly.GetEventHandle(), INFINITE, TRUE); + switch(dwResult) + { + case STATUS_USER_APC: + break; - case WAIT_OBJECT_0: - return; + case WAIT_OBJECT_0: + bStop = true; + break; - default: - throw TCoreException(eErr_UnhandledCase, L"Unknown result from async waiting function", LOCATION); + default: + throw TCoreException(eErr_UnhandledCase, L"Unknown result from async waiting function", LOCATION); + } } + while(!bStop); } TSubTaskBase::ESubOperationResult TOverlappedWriterFB::StopThreaded() { - WaitForSingleObjectEx(m_eventProcessingFinished.Handle(), INFINITE, FALSE); + DWORD dwResult = WaitForSingleObjectEx(m_eventProcessingFinished.Handle(), INFINITE, FALSE); + _ASSERTE(dwResult == WAIT_OBJECT_0); dwResult; + return m_eThreadResult; } } Index: src/libchcore/TWriteBufferQueueWrapper.cpp =================================================================== diff -u -rc719644bb4360fcf7ccf6f1139bcae852bd6effd -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/TWriteBufferQueueWrapper.cpp (.../TWriteBufferQueueWrapper.cpp) (revision c719644bb4360fcf7ccf6f1139bcae852bd6effd) +++ src/libchcore/TWriteBufferQueueWrapper.cpp (.../TWriteBufferQueueWrapper.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -89,7 +89,7 @@ void TWriteBufferQueueWrapper::ClearBuffers(const TBufferListPtr& spEmptyBuffers) { - m_spDataQueue->ClearBuffers(spEmptyBuffers); + m_spDataQueue->ClearBuffers(); m_tRetryBuffers.ClearBuffers(spEmptyBuffers); } Index: src/libchcore/Tests/TOrderedBufferQueueTests.cpp =================================================================== diff -u -rb051cbac8dac8c448507aa7c64753af9cf793af5 -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/Tests/TOrderedBufferQueueTests.cpp (.../TOrderedBufferQueueTests.cpp) (revision b051cbac8dac8c448507aa7c64753af9cf793af5) +++ src/libchcore/Tests/TOrderedBufferQueueTests.cpp (.../TOrderedBufferQueueTests.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -20,7 +20,8 @@ // expected position mode TEST(TOrderedBufferQueueTests, ExpectedPos_ConstructionSanityTest) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); EXPECT_EQ(0, queue.GetCount()); EXPECT_EQ(true, queue.IsEmpty()); @@ -30,7 +31,8 @@ TEST(TOrderedBufferQueueTests, ExpectedPos_PushAtExpectedPosition) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer(1024, nullptr); buffer.SetFilePosition(0); @@ -44,7 +46,8 @@ TEST(TOrderedBufferQueueTests, ExpectedPos_PushAtOtherPosition) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer(1024, nullptr); buffer.SetFilePosition(1000); @@ -59,7 +62,8 @@ TEST(TOrderedBufferQueueTests, ExpectedPos_PushOutOfOrder) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer1(1024, nullptr); buffer1.SetFilePosition(1000); buffer1.SetRequestedDataSize(1000); @@ -80,7 +84,8 @@ TEST(TOrderedBufferQueueTests, ExpectedPos_Pop) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer(1024, nullptr); queue.Push(&buffer); @@ -94,27 +99,27 @@ TEST(TOrderedBufferQueueTests, ExpectedPos_ReleaseBuffers) { - TOrderedBufferQueue queue(0); - TBufferListPtr spReleaseList(std::make_shared()); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer(1024, nullptr); queue.Push(&buffer); - queue.ClearBuffers(spReleaseList); + queue.ClearBuffers(); - EXPECT_EQ(1, spReleaseList->GetCount()); + EXPECT_EQ(1, spEmptyBuffers->GetCount()); } TEST(TOrderedBufferQueueTests, ExpectedPos_ReleaseBuffersUnordered) { - TOrderedBufferQueue queue(0); - TBufferListPtr spReleaseList(std::make_shared()); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer(1024, nullptr); buffer.SetFilePosition(1000); queue.Push(&buffer); - queue.ClearBuffers(spReleaseList); + queue.ClearBuffers(); - EXPECT_EQ(1, spReleaseList->GetCount()); + EXPECT_EQ(1, spEmptyBuffers->GetCount()); } /////////////////////////////////////////////////////////////////////////////////////////// @@ -125,7 +130,8 @@ TEST(TOrderedBufferQueueTests, ConstructionSanityTest) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); EXPECT_EQ(0, queue.GetCount()); EXPECT_TIMEOUT(queue.GetHasErrorEvent()); @@ -137,7 +143,8 @@ TEST(TOrderedBufferQueueTests, PushBuffer_FirstFailure) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer(4096, nullptr); buffer.SetErrorCode(123); @@ -151,7 +158,8 @@ TEST(TOrderedBufferQueueTests, PushBuffer_TwoSubsequentFailures) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer1(4096, nullptr); TOverlappedDataBuffer buffer2(4096, nullptr); buffer1.SetFilePosition(0); @@ -174,7 +182,8 @@ TEST(TOrderedBufferQueueTests, PushBuffer_TwoFailuresOutOfOrder) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer1(4096, nullptr); TOverlappedDataBuffer buffer2(4096, nullptr); buffer1.SetFilePosition(0); @@ -197,7 +206,8 @@ TEST(TOrderedBufferQueueTests, PushBuffer_ThrowOnNonErrorBuffer) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer1(4096, nullptr); buffer1.SetFilePosition(0); buffer1.SetErrorCode(ERROR_SUCCESS); @@ -212,13 +222,15 @@ TEST(TOrderedBufferQueueTests, PopBuffer_EmptyContainer) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); EXPECT_EQ(nullptr, queue.Pop()); } TEST(TOrderedBufferQueueTests, PopBuffer_WithSamePosition) { - TOrderedBufferQueue queue(0); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueue queue(spEmptyBuffers, 0); TOverlappedDataBuffer buffer1(4096, nullptr); TOverlappedDataBuffer buffer2(4096, nullptr); TOverlappedDataBuffer buffer3(4096, nullptr); Index: src/libchcore/Tests/TOverlappedWriterTests.cpp =================================================================== diff -u -rf1d25f23712f5de7459f690ab51b2640d0f81b91 -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/Tests/TOverlappedWriterTests.cpp (.../TOverlappedWriterTests.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) +++ src/libchcore/Tests/TOverlappedWriterTests.cpp (.../TOverlappedWriterTests.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -11,7 +11,7 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TBufferListPtr spEmptyBuffers(std::make_shared()); - TOrderedBufferQueuePtr spQueue(std::make_shared(0)); + TOrderedBufferQueuePtr spQueue(std::make_shared(spEmptyBuffers, 0)); TOverlappedProcessorRangePtr spRange(std::make_shared(0)); TOverlappedWriter tWriter(spLogData, spQueue, spRange, spEmptyBuffers); @@ -33,7 +33,7 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TBufferListPtr spEmptyBuffers(std::make_shared()); - TOrderedBufferQueuePtr spQueue(std::make_shared(0)); + TOrderedBufferQueuePtr spQueue(std::make_shared(spEmptyBuffers, 0)); TOverlappedProcessorRangePtr spRange(std::make_shared(0)); TOverlappedWriter tWriter(spLogData, spQueue, spRange, spEmptyBuffers); Index: src/libchcore/Tests/TReadBufferQueueWrapperTests.cpp =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/Tests/TReadBufferQueueWrapperTests.cpp (.../TReadBufferQueueWrapperTests.cpp) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/Tests/TReadBufferQueueWrapperTests.cpp (.../TReadBufferQueueWrapperTests.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -191,11 +191,11 @@ queue.SetDataSourceFinished(&buffer1); - EXPECT_EQ(1, queue.GetCount()); + EXPECT_EQ(2, queue.GetCount()); EXPECT_EQ(&buffer1, queue.Pop()); - EXPECT_EQ(1, spList->GetCount()); - EXPECT_EQ(&buffer2, spList->Pop()); + EXPECT_EQ(0, spList->GetCount()); + EXPECT_EQ(nullptr, spList->Pop()); } TEST(TReadBufferQueueWrapperTests, PushPop_DataSourceFinished_ValidPushAfterFinished) Index: src/libchcore/Tests/TSimpleOrderedBufferQueueTests.cpp =================================================================== diff -u -rb051cbac8dac8c448507aa7c64753af9cf793af5 -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/Tests/TSimpleOrderedBufferQueueTests.cpp (.../TSimpleOrderedBufferQueueTests.cpp) (revision b051cbac8dac8c448507aa7c64753af9cf793af5) +++ src/libchcore/Tests/TSimpleOrderedBufferQueueTests.cpp (.../TSimpleOrderedBufferQueueTests.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -11,8 +11,8 @@ { TSimpleOrderedBufferQueue queue; - EXPECT_EQ(0, queue.size()); - EXPECT_EQ(true, queue.empty()); + EXPECT_EQ(0, queue.GetCount()); + EXPECT_EQ(true, queue.IsEmpty()); EXPECT_EQ(nullptr, queue.Peek()); } @@ -23,8 +23,8 @@ queue.Push(&buffer); - EXPECT_EQ(1, queue.size()); - EXPECT_EQ(false, queue.empty()); + EXPECT_EQ(1, queue.GetCount()); + EXPECT_EQ(false, queue.IsEmpty()); EXPECT_EQ(&buffer, queue.Peek()); } @@ -45,21 +45,22 @@ queue.Push(&buffer); EXPECT_EQ(&buffer, queue.Pop()); - EXPECT_EQ(0, queue.size()); - EXPECT_EQ(true, queue.empty()); + EXPECT_EQ(0, queue.GetCount()); + EXPECT_EQ(true, queue.IsEmpty()); EXPECT_EQ(nullptr, queue.Peek()); } TEST(TSimpleOrderedBufferQueueTests, Clear) { TSimpleOrderedBufferQueue queue; TOverlappedDataBuffer buffer(1024, nullptr); + TBufferListPtr spEmptyBuffers(std::make_shared()); queue.Push(&buffer); - queue.clear(); + queue.ClearBuffers(spEmptyBuffers); - EXPECT_EQ(0, queue.size()); - EXPECT_EQ(true, queue.empty()); + EXPECT_EQ(0, queue.GetCount()); + EXPECT_EQ(true, queue.IsEmpty()); EXPECT_EQ(nullptr, queue.Peek()); } Index: src/libchcore/Tests/TWriteBufferQueueWrapperTests.cpp =================================================================== diff -u -r685d0da3259dd94327ee8d644a88c155585b8249 -r518d1a3484cde91ff17c071211df5e40cb3487e3 --- src/libchcore/Tests/TWriteBufferQueueWrapperTests.cpp (.../TWriteBufferQueueWrapperTests.cpp) (revision 685d0da3259dd94327ee8d644a88c155585b8249) +++ src/libchcore/Tests/TWriteBufferQueueWrapperTests.cpp (.../TWriteBufferQueueWrapperTests.cpp) (revision 518d1a3484cde91ff17c071211df5e40cb3487e3) @@ -15,7 +15,8 @@ TEST(TWriteBufferQueueWrapperTests, Constructor) { - TOrderedBufferQueuePtr spQueue(std::make_shared(0)); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueuePtr spQueue(std::make_shared(spEmptyBuffers, 0)); TWriteBufferQueueWrapper queue(spQueue); EXPECT_EQ(0, queue.GetCount()); @@ -24,15 +25,19 @@ TEST(TWriteBufferQueueWrapperTests, Pop_EmptyQueue) { - TOrderedBufferQueuePtr spQueue(std::make_shared(0)); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueuePtr spQueue(std::make_shared(spEmptyBuffers, 0)); + TWriteBufferQueueWrapper queue(spQueue); EXPECT_EQ(nullptr, queue.Pop()); } TEST(TWriteBufferQueueWrapperTests, Pop_FromBufferList) { - TOrderedBufferQueuePtr spQueue(std::make_shared(0)); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueuePtr spQueue(std::make_shared(spEmptyBuffers, 0)); + TOverlappedDataBuffer buffer1(1024, nullptr); buffer1.SetFilePosition(0); buffer1.SetRequestedDataSize(1000); @@ -74,7 +79,9 @@ TEST(TWriteBufferQueueWrapperTests, PushPop_ClaimedBuffers) { - TOrderedBufferQueuePtr spQueue(std::make_shared(0)); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueuePtr spQueue(std::make_shared(spEmptyBuffers, 0)); + TWriteBufferQueueWrapper queue(spQueue); TOverlappedDataBuffer buffer1(1024, nullptr); @@ -121,7 +128,9 @@ TEST(TWriteBufferQueueWrapperTests, PushPop_MixedBuffers) { - TOrderedBufferQueuePtr spQueue(std::make_shared(0)); + TBufferListPtr spEmptyBuffers(std::make_shared()); + TOrderedBufferQueuePtr spQueue(std::make_shared(spEmptyBuffers, 0)); + TOverlappedDataBuffer buffer1(1024, nullptr); buffer1.SetFilePosition(0); buffer1.SetRequestedDataSize(1000);