Index: src/libchcore/TOrderedBufferQueue.cpp =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOrderedBufferQueue.cpp (.../TOrderedBufferQueue.cpp) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/TOrderedBufferQueue.cpp (.../TOrderedBufferQueue.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -160,4 +160,12 @@ { return m_notifier; } + + void TOrderedBufferQueue::UpdateProcessingRange(unsigned long long ullNewPosition) + { + if(!m_setBuffers.empty()) + throw TCoreException(eErr_InvalidData, L"Cannot update processing range when processing already started", LOCATION); + + m_ullExpectedBufferPosition = ullNewPosition; + } } Index: src/libchcore/TOrderedBufferQueue.h =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOrderedBufferQueue.h (.../TOrderedBufferQueue.h) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/TOrderedBufferQueue.h (.../TOrderedBufferQueue.h) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -56,6 +56,8 @@ boost::signals2::signal& GetNotifier(); + void UpdateProcessingRange(unsigned long long ullNewPosition); + private: void UpdateHasBuffers(); void UpdateHasErrors(); Index: src/libchcore/TOverlappedProcessorRange.cpp =================================================================== diff -u --- src/libchcore/TOverlappedProcessorRange.cpp (revision 0) +++ src/libchcore/TOverlappedProcessorRange.cpp (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -0,0 +1,51 @@ +// ============================================================================ +// Copyright (C) 2001-2016 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#include "stdafx.h" +#include "TOverlappedProcessorRange.h" + +namespace chcore +{ + TOverlappedProcessorRange::TOverlappedProcessorRange() + { + } + + TOverlappedProcessorRange::TOverlappedProcessorRange(unsigned long long ullResumePosition) : + m_ullResumePosition(ullResumePosition) + { + } + + void TOverlappedProcessorRange::SetResumePosition(unsigned long long ullResumePosition) + { + if(m_ullResumePosition != ullResumePosition) + { + m_ullResumePosition = ullResumePosition; + m_notifier(ullResumePosition); + } + } + + unsigned long long TOverlappedProcessorRange::GetResumePosition() const + { + return m_ullResumePosition; + } + + boost::signals2::signal& TOverlappedProcessorRange::GetNotifier() + { + return m_notifier; + } +} Index: src/libchcore/TOverlappedProcessorRange.h =================================================================== diff -u --- src/libchcore/TOverlappedProcessorRange.h (revision 0) +++ src/libchcore/TOverlappedProcessorRange.h (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -0,0 +1,45 @@ +// ============================================================================ +// Copyright (C) 2001-2016 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +#ifndef __TOVERLAPPEDPROCESSORRANGE_H__ +#define __TOVERLAPPEDPROCESSORRANGE_H__ + +#include + +namespace chcore +{ + class TOverlappedProcessorRange + { + public: + TOverlappedProcessorRange(); + TOverlappedProcessorRange(unsigned long long ullResumePosition); + + void SetResumePosition(unsigned long long ullResumePosition); + unsigned long long GetResumePosition() const; + + boost::signals2::signal& GetNotifier(); + + private: + unsigned long long m_ullResumePosition = 0; + boost::signals2::signal m_notifier; + }; + + using TOverlappedProcessorRangePtr = std::shared_ptr; +} + +#endif Index: src/libchcore/TOverlappedReader.cpp =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedReader.cpp (.../TOverlappedReader.cpp) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/TOverlappedReader.cpp (.../TOverlappedReader.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -25,20 +25,26 @@ namespace chcore { TOverlappedReader::TOverlappedReader(const logger::TLogFileDataPtr& spLogFileData, const TBufferListPtr& spEmptyBuffers, - unsigned long long ullFilePos, DWORD dwChunkSize) : + const TOverlappedProcessorRangePtr& spDataRange, + DWORD dwChunkSize) : m_spLog(logger::MakeLogger(spLogFileData, L"DataBuffer")), m_spEmptyBuffers(spEmptyBuffers), - m_tInputBuffers(spEmptyBuffers, ullFilePos, dwChunkSize), - m_spFullBuffers(std::make_shared(ullFilePos)) + m_tInputBuffers(spEmptyBuffers, spDataRange ? spDataRange->GetResumePosition() : 0, dwChunkSize), + m_spFullBuffers(std::make_shared(spDataRange ? spDataRange->GetResumePosition() : 0)) { if(!spLogFileData) throw TCoreException(eErr_InvalidArgument, L"spLogFileData is NULL", LOCATION); if(!spEmptyBuffers) throw TCoreException(eErr_InvalidArgument, L"spMemoryPool", LOCATION); + if(!spDataRange) + throw TCoreException(eErr_InvalidArgument, L"spDataRange is NULL", LOCATION); + + m_dataRangeChanged = spDataRange->GetNotifier().connect(boost::bind(&TOverlappedReader::UpdateProcessingRange, this, _1)); } TOverlappedReader::~TOverlappedReader() { + m_dataRangeChanged.disconnect(); } TOverlappedDataBuffer* TOverlappedReader::GetEmptyBuffer() @@ -178,6 +184,12 @@ m_spFullBuffers->ReleaseBuffers(m_spEmptyBuffers); } + void TOverlappedReader::UpdateProcessingRange(unsigned long long ullNewPosition) + { + m_tInputBuffers.UpdateProcessingRange(ullNewPosition); + m_spFullBuffers->UpdateProcessingRange(ullNewPosition); + } + HANDLE TOverlappedReader::GetEventReadPossibleHandle() const { return m_tInputBuffers.GetHasBuffersEvent(); Index: src/libchcore/TOverlappedReader.h =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedReader.h (.../TOverlappedReader.h) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/TOverlappedReader.h (.../TOverlappedReader.h) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -23,14 +23,17 @@ #include "../liblogger/TLogger.h" #include "TOrderedBufferQueue.h" #include "TReadBufferQueueWrapper.h" +#include "TOverlappedProcessorRange.h" namespace chcore { class TOverlappedReader { public: - explicit TOverlappedReader(const logger::TLogFileDataPtr& spLogFileData, const TBufferListPtr& spEmptyBuffers, - unsigned long long ullFilePos, DWORD dwChunkSize); + explicit TOverlappedReader(const logger::TLogFileDataPtr& spLogFileData, + const TBufferListPtr& spEmptyBuffers, + const TOverlappedProcessorRangePtr& spDataRange, + DWORD dwChunkSize); TOverlappedReader(const TOverlappedReader&) = delete; ~TOverlappedReader(); @@ -59,6 +62,8 @@ void ReleaseBuffers(); + void UpdateProcessingRange(unsigned long long ullNewPosition); + private: logger::TLoggerPtr m_spLog; @@ -68,6 +73,8 @@ TOrderedBufferQueuePtr m_spFullBuffers; // buffers with data bool m_bReleaseMode = false; // when set, all incoming buffers will go to empty buffers + + boost::signals2::connection m_dataRangeChanged; }; using TOverlappedReaderPtr = std::shared_ptr; Index: src/libchcore/TOverlappedReaderFB.cpp =================================================================== diff -u -r8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedReaderFB.cpp (.../TOverlappedReaderFB.cpp) (revision 8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e) +++ src/libchcore/TOverlappedReaderFB.cpp (.../TOverlappedReaderFB.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -23,21 +23,34 @@ namespace chcore { - TOverlappedReaderFB::TOverlappedReaderFB(const TFilesystemFileFeedbackWrapperPtr& spSrcFile, const TSubTaskStatsInfoPtr& spStats, + TOverlappedReaderFB::TOverlappedReaderFB(const IFilesystemPtr& spFilesystem, + const IFeedbackHandlerPtr& spFeedbackHandler, + TWorkerThreadController& rThreadController, + const TSubTaskStatsInfoPtr& spStats, const TFileInfoPtr& spSrcFileInfo, - const logger::TLogFileDataPtr& spLogFileData, const TBufferListPtr& spEmptyBuffers, - unsigned long long ullFilePos, DWORD dwChunkSize) : - m_spReader(std::make_shared(spLogFileData, spEmptyBuffers, ullFilePos, dwChunkSize)), - m_spSrcFile(spSrcFile), + const logger::TLogFileDataPtr& spLogFileData, + const TBufferListPtr& spEmptyBuffers, + const TOverlappedProcessorRangePtr& spDataRange, + DWORD dwChunkSize, + bool bNoBuffering, + bool bProtectReadOnlyFiles) : + m_spReader(std::make_shared(spLogFileData, spEmptyBuffers, spDataRange, dwChunkSize)), + m_spFilesystem(spFilesystem), + m_spSrcFile(), m_spStats(spStats), m_spSrcFileInfo(spSrcFileInfo) { - if(!spSrcFile) - throw TCoreException(eErr_InvalidArgument, L"spSrcFile is NULL", LOCATION); + if(!spFeedbackHandler) + throw TCoreException(eErr_InvalidArgument, L"spFeedbackHandler is NULL", LOCATION); + if(!spFilesystem) + throw TCoreException(eErr_InvalidArgument, L"spFilesystem is NULL", LOCATION); if(!spStats) throw TCoreException(eErr_InvalidArgument, L"spStats is NULL", LOCATION); if(!spSrcFileInfo) throw TCoreException(eErr_InvalidArgument, L"spSrcFileInfo is NULL", LOCATION); + + IFilesystemFilePtr fileSrc = m_spFilesystem->CreateFileObject(IFilesystemFile::eMode_Read, m_spSrcFileInfo->GetFullFilePath(), bNoBuffering, bProtectReadOnlyFiles); + m_spSrcFile = std::make_shared(fileSrc, spFeedbackHandler, spLogFileData, rThreadController, spFilesystem); } TOverlappedReaderFB::~TOverlappedReaderFB() @@ -46,6 +59,17 @@ TSubTaskBase::ESubOperationResult TOverlappedReaderFB::Start() { + TSubTaskBase::ESubOperationResult eResult = UpdateFileStats(); + return eResult; + } + + TOverlappedReaderPtr TOverlappedReaderFB::GetReader() const + { + return m_spReader; + } + + TSubTaskBase::ESubOperationResult TOverlappedReaderFB::UpdateFileStats() + { // update the source file size (it might differ from the time this file was originally scanned). // NOTE: this kind of update could be also done when copying chunks of data beyond the original end-of-file, // but it would require frequent total size updates and thus - serializations). Index: src/libchcore/TOverlappedReaderFB.h =================================================================== diff -u -r8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedReaderFB.h (.../TOverlappedReaderFB.h) (revision 8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e) +++ src/libchcore/TOverlappedReaderFB.h (.../TOverlappedReaderFB.h) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -21,6 +21,7 @@ #include "TOverlappedReader.h" #include "TFilesystemFileFeedbackWrapper.h" +#include "TOverlappedProcessorRange.h" namespace chcore { @@ -29,22 +30,34 @@ class TOverlappedReaderFB { public: - TOverlappedReaderFB(const TFilesystemFileFeedbackWrapperPtr& spSrcFile, const TSubTaskStatsInfoPtr& spStats, + TOverlappedReaderFB(const IFilesystemPtr& spFilesystem, + const IFeedbackHandlerPtr& spFeedbackHandler, + TWorkerThreadController& rThreadController, + const TSubTaskStatsInfoPtr& spStats, const TFileInfoPtr& spSrcFileInfo, - const logger::TLogFileDataPtr& spLogFileData, const TBufferListPtr& spEmptyBuffers, - unsigned long long ullFilePos, DWORD dwChunkSize); + const logger::TLogFileDataPtr& spLogFileData, + const TBufferListPtr& spEmptyBuffers, + const TOverlappedProcessorRangePtr& spDataRange, + DWORD dwChunkSize, + bool bNoBuffering, + bool bProtectReadOnlyFiles); ~TOverlappedReaderFB(); TSubTaskBase::ESubOperationResult Start(); - TOverlappedReaderPtr GetReader() const { return m_spReader; } + TOverlappedReaderPtr GetReader() const; void SetReleaseMode(); TSubTaskBase::ESubOperationResult OnReadPossible(); TSubTaskBase::ESubOperationResult OnReadFailed(); private: + TSubTaskBase::ESubOperationResult UpdateFileStats(); + + private: TOverlappedReaderPtr m_spReader; + + IFilesystemPtr m_spFilesystem; TFilesystemFileFeedbackWrapperPtr m_spSrcFile; TSubTaskStatsInfoPtr m_spStats; TFileInfoPtr m_spSrcFileInfo; Index: src/libchcore/TOverlappedReaderWriterFB.cpp =================================================================== diff -u -r8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedReaderWriterFB.cpp (.../TOverlappedReaderWriterFB.cpp) (revision 8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e) +++ src/libchcore/TOverlappedReaderWriterFB.cpp (.../TOverlappedReaderWriterFB.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -21,18 +21,30 @@ #include "TCoreException.h" #include "ErrorCodes.h" #include +#include "TWorkerThreadController.h" namespace chcore { - TOverlappedReaderWriterFB::TOverlappedReaderWriterFB(const TFilesystemFileFeedbackWrapperPtr& spSrcFile, const TFileInfoPtr& spSrcFileInfo, - const TFilesystemFileFeedbackWrapperPtr& spDstFile, + TOverlappedReaderWriterFB::TOverlappedReaderWriterFB(const IFilesystemPtr& spFilesystem, + const IFeedbackHandlerPtr& spFeedbackHandler, + TWorkerThreadController& rThreadController, + const TFileInfoPtr& spSrcFileInfo, + const TSmartPath& pathDst, const TSubTaskStatsInfoPtr& spStats, - const logger::TLogFileDataPtr& spLogFileData, const TOverlappedMemoryPoolPtr& spMemoryPool, unsigned long long ullFilePos, DWORD dwChunkSize) : + const logger::TLogFileDataPtr& spLogFileData, + const TOverlappedMemoryPoolPtr& spMemoryPool, + unsigned long long ullResumePosition, + DWORD dwChunkSize, + bool bNoBuffering, + bool bProtectReadOnlyFiles, + bool bOnlyCreate) : m_spLog(logger::MakeLogger(spLogFileData, L"DataBuffer")), + m_rThreadController(rThreadController), + m_spRange(std::make_shared(ullResumePosition)), m_spMemoryPool(spMemoryPool), - m_spReader(std::make_shared(spSrcFile, spStats, spSrcFileInfo, spLogFileData, spMemoryPool->GetBufferList(), ullFilePos, dwChunkSize)), - m_spWriter(std::make_shared(spSrcFile, spDstFile, spStats, spSrcFileInfo, spLogFileData, m_spReader->GetReader()->GetFinishedQueue(), ullFilePos, spMemoryPool->GetBufferList())) + m_spReader(std::make_shared(spFilesystem, spFeedbackHandler, rThreadController, spStats, spSrcFileInfo, spLogFileData, spMemoryPool->GetBufferList(), m_spRange, dwChunkSize, bNoBuffering, bProtectReadOnlyFiles)), + m_spWriter(std::make_shared(spFilesystem, spFeedbackHandler, rThreadController, spStats, spSrcFileInfo, pathDst, spLogFileData, m_spReader->GetReader()->GetFinishedQueue(), m_spRange, spMemoryPool->GetBufferList(), bOnlyCreate, bNoBuffering, bProtectReadOnlyFiles)) { if(!spMemoryPool) throw TCoreException(eErr_InvalidArgument, L"spMemoryPool", LOCATION); @@ -104,13 +116,13 @@ return eResult; } - TSubTaskBase::ESubOperationResult TOverlappedReaderWriterFB::Start(HANDLE hKill, bool bCreateOnly) + TSubTaskBase::ESubOperationResult TOverlappedReaderWriterFB::Start() { TSubTaskBase::ESubOperationResult eResult = m_spReader->Start(); if(eResult != TSubTaskBase::eSubResult_Continue) return eResult; - eResult = m_spWriter->Start(bCreateOnly); + eResult = m_spWriter->Start(); if(eResult != TSubTaskBase::eSubResult_Continue) return eResult; @@ -127,7 +139,7 @@ }; std::array arrHandles = { - hKill, + m_rThreadController.GetKillThreadHandle(), m_spWriter->GetWriter()->GetEventWriteFinishedHandle(), m_spWriter->GetWriter()->GetEventWriteFailedHandle(), m_spWriter->GetWriter()->GetEventWritePossibleHandle(), Index: src/libchcore/TOverlappedReaderWriterFB.h =================================================================== diff -u -r8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedReaderWriterFB.h (.../TOverlappedReaderWriterFB.h) (revision 8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e) +++ src/libchcore/TOverlappedReaderWriterFB.h (.../TOverlappedReaderWriterFB.h) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -30,17 +30,25 @@ class TOverlappedReaderWriterFB { public: - explicit TOverlappedReaderWriterFB(const TFilesystemFileFeedbackWrapperPtr& spSrcFile, const TFileInfoPtr& spSrcFileInfo, - const TFilesystemFileFeedbackWrapperPtr& spDstFile, + explicit TOverlappedReaderWriterFB(const IFilesystemPtr& spFilesystem, + const IFeedbackHandlerPtr& spFeedbackHandler, + TWorkerThreadController& rThreadController, + const TFileInfoPtr& spSrcFileInfo, + const TSmartPath& pathDst, const TSubTaskStatsInfoPtr& spStats, - const logger::TLogFileDataPtr& spLogFileData, const TOverlappedMemoryPoolPtr& spBuffers, - unsigned long long ullFilePos, DWORD dwChunkSize); + const logger::TLogFileDataPtr& spLogFileData, + const TOverlappedMemoryPoolPtr& spBuffers, + unsigned long long ullResumePosition, + DWORD dwChunkSize, + bool bNoBuffering, + bool bProtectReadOnlyFiles, + bool bOnlyCreate); TOverlappedReaderWriterFB(const TOverlappedReaderWriterFB&) = delete; ~TOverlappedReaderWriterFB(); TOverlappedReaderWriterFB& operator=(const TOverlappedReaderWriterFB&) = delete; - TSubTaskBase::ESubOperationResult Start(HANDLE hKill, bool bCreateOnly); + TSubTaskBase::ESubOperationResult Start(); // reader/writer TOverlappedReaderFBPtr GetReader() const { return m_spReader; } @@ -51,7 +59,10 @@ private: logger::TLoggerPtr m_spLog; + TWorkerThreadController& m_rThreadController; + TOverlappedProcessorRangePtr m_spRange; + TOverlappedMemoryPoolPtr m_spMemoryPool; TOverlappedReaderFBPtr m_spReader; TOverlappedWriterFBPtr m_spWriter; Index: src/libchcore/TOverlappedWriter.cpp =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedWriter.cpp (.../TOverlappedWriter.cpp) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/TOverlappedWriter.cpp (.../TOverlappedWriter.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -25,19 +25,22 @@ namespace chcore { TOverlappedWriter::TOverlappedWriter(const logger::TLogFileDataPtr& spLogFileData, const TOrderedBufferQueuePtr& spBuffersToWrite, - unsigned long long ullFilePos, const TBufferListPtr& spEmptyBuffers) : + const TOverlappedProcessorRangePtr& spRange, const TBufferListPtr& spEmptyBuffers) : m_spLog(logger::MakeLogger(spLogFileData, L"DataBuffer")), m_spEmptyBuffers(spEmptyBuffers), m_tBuffersToWrite(spBuffersToWrite), - m_tFinishedBuffers(ullFilePos) + m_tFinishedBuffers(spRange != nullptr ? spRange->GetResumePosition() : 0) { if(!spLogFileData) throw TCoreException(eErr_InvalidArgument, L"spLogFileData is NULL", LOCATION); if(!spBuffersToWrite) throw TCoreException(eErr_InvalidArgument, L"spBuffersToWrite is NULL", LOCATION); if(!spEmptyBuffers) throw TCoreException(eErr_InvalidArgument, L"spEmptyBuffers is NULL", LOCATION); + if(!spRange) + throw TCoreException(eErr_InvalidArgument, L"spRange is NULL", LOCATION); + m_dataRangeChanged = spRange->GetNotifier().connect(boost::bind(&TOverlappedWriter::UpdateProcessingRange, this, _1)); } TOverlappedWriter::~TOverlappedWriter() @@ -152,6 +155,11 @@ return m_tFinishedBuffers.GetHasBuffersEvent(); } + void TOverlappedWriter::UpdateProcessingRange(unsigned long long ullNewPosition) + { + m_tFinishedBuffers.UpdateProcessingRange(ullNewPosition); + } + void TOverlappedWriter::AddFinishedBuffer(TOverlappedDataBuffer* pBuffer) { if (!pBuffer) Index: src/libchcore/TOverlappedWriter.h =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedWriter.h (.../TOverlappedWriter.h) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/TOverlappedWriter.h (.../TOverlappedWriter.h) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -24,14 +24,15 @@ #include "TOrderedBufferQueue.h" #include "TWriteBufferQueueWrapper.h" #include "TBufferList.h" +#include "TOverlappedProcessorRange.h" namespace chcore { class TOverlappedWriter { public: explicit TOverlappedWriter(const logger::TLogFileDataPtr& spLogFileData, const TOrderedBufferQueuePtr& spBuffersToWrite, - unsigned long long ullFilePos, const TBufferListPtr& spEmptyBuffers); + const TOverlappedProcessorRangePtr& spRange, const TBufferListPtr& spEmptyBuffers); TOverlappedWriter(const TOverlappedWriter&) = delete; ~TOverlappedWriter(); @@ -57,6 +58,8 @@ HANDLE GetEventWriteFailedHandle() const; HANDLE GetEventWriteFinishedHandle() const; + void UpdateProcessingRange(unsigned long long ullNewPosition); + private: logger::TLoggerPtr m_spLog; @@ -66,6 +69,8 @@ TOrderedBufferQueue m_tFinishedBuffers; TOverlappedDataBuffer* m_pLastPartBuffer = nullptr; + + boost::signals2::connection m_dataRangeChanged; }; using TOverlappedWriterPtr = std::shared_ptr; Index: src/libchcore/TOverlappedWriterFB.cpp =================================================================== diff -u -r8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedWriterFB.cpp (.../TOverlappedWriterFB.cpp) (revision 8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e) +++ src/libchcore/TOverlappedWriterFB.cpp (.../TOverlappedWriterFB.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -24,25 +24,40 @@ namespace chcore { - TOverlappedWriterFB::TOverlappedWriterFB(const TFilesystemFileFeedbackWrapperPtr& spSrcFile, const TFilesystemFileFeedbackWrapperPtr& spDstFile, + TOverlappedWriterFB::TOverlappedWriterFB(const IFilesystemPtr& spFilesystem, + const IFeedbackHandlerPtr& spFeedbackHandler, + TWorkerThreadController& rThreadController, const TSubTaskStatsInfoPtr& spStats, const TFileInfoPtr& spSrcFileInfo, - const logger::TLogFileDataPtr& spLogFileData, const TOrderedBufferQueuePtr& spBuffersToWrite, - unsigned long long ullFilePos, const TBufferListPtr& spEmptyBuffers) : - m_spWriter(std::make_shared(spLogFileData, spBuffersToWrite, ullFilePos, spEmptyBuffers)), - m_spSrcFile(spSrcFile), - m_spDstFile(spDstFile), + const TSmartPath& pathDst, + const logger::TLogFileDataPtr& spLogFileData, + const TOrderedBufferQueuePtr& spBuffersToWrite, + const TOverlappedProcessorRangePtr& spRange, + const TBufferListPtr& spEmptyBuffers, + bool bOnlyCreate, + bool bNoBuffering, + bool bProtectReadOnlyFiles) : + m_spWriter(std::make_shared(spLogFileData, spBuffersToWrite, spRange, spEmptyBuffers)), m_spStats(spStats), - m_spSrcFileInfo(spSrcFileInfo) + m_spSrcFileInfo(spSrcFileInfo), + m_spDataRange(spRange), + m_bOnlyCreate(bOnlyCreate) { - if(!spDstFile) - throw TCoreException(eErr_InvalidArgument, L"spDstFile is NULL", LOCATION); + if(!spFilesystem) + throw TCoreException(eErr_InvalidArgument, L"spFilesystem is NULL", LOCATION); + if(!spFeedbackHandler) + throw TCoreException(eErr_InvalidArgument, L"spFeedbackHandler is NULL", LOCATION); if(!spStats) throw TCoreException(eErr_InvalidArgument, L"spStats is NULL", LOCATION); if(!spSrcFileInfo) throw TCoreException(eErr_InvalidArgument, L"spSrcFileInfo is NULL", LOCATION); if(!spEmptyBuffers) throw TCoreException(eErr_InvalidArgument, L"spEmptyBuffers is NULL", LOCATION); + if(!spRange) + throw TCoreException(eErr_InvalidArgument, L"spRange is NULL", LOCATION); + + IFilesystemFilePtr fileDst = spFilesystem->CreateFileObject(IFilesystemFile::eMode_Write, pathDst, bNoBuffering, bProtectReadOnlyFiles); + m_spDstFile = std::make_shared(fileDst, spFeedbackHandler, spLogFileData, rThreadController, spFilesystem); } TOverlappedWriterFB::~TOverlappedWriterFB() @@ -103,7 +118,7 @@ if(m_bReleaseMode) { - AdjustProcessedSize(fsWritten); // ignore return value as we're already in release mode + AdjustProcessedSize(fsWritten); m_spWriter->AddEmptyBuffer(pBuffer); @@ -122,12 +137,7 @@ } // in case we read past the original eof, try to get new file size from filesystem - eResult = AdjustProcessedSize(fsWritten); - if(eResult != TSubTaskBase::eSubResult_Continue) - { - m_spWriter->AddEmptyBuffer(pBuffer); - return eResult; - } + AdjustProcessedSize(fsWritten); // stop iterating through file bStopProcessing = pBuffer->IsLastPart(); @@ -150,28 +160,13 @@ return eResult; } - TSubTaskBase::ESubOperationResult TOverlappedWriterFB::AdjustProcessedSize(file_size_t fsWritten) + void TOverlappedWriterFB::AdjustProcessedSize(file_size_t fsWritten) { - TSubTaskBase::ESubOperationResult eResult = TSubTaskBase::eSubResult_Continue; - // in case we read past the original eof, try to get new file size from filesystem if(m_spStats->WillAdjustProcessedSizeExceedTotalSize(0, fsWritten)) - { - file_size_t fsNewSize = 0; - eResult = m_spSrcFile->GetFileSize(fsNewSize); - if(eResult != TSubTaskBase::eSubResult_Continue) - return eResult; + throw TCoreException(eErr_InternalProblem, L"Read more data from file than it really contained. Possible destination file corruption.", LOCATION); - if(fsNewSize == m_spSrcFileInfo->GetLength64()) - throw TCoreException(eErr_InternalProblem, L"Read more data from file than it really contained. Possible destination file corruption.", LOCATION); - - m_spStats->AdjustTotalSize(m_spSrcFileInfo->GetLength64(), fsNewSize); - m_spSrcFileInfo->SetLength64(m_spStats->GetCurrentItemTotalSize()); - } - m_spStats->AdjustProcessedSize(0, fsWritten); - - return eResult; } TSubTaskBase::ESubOperationResult TOverlappedWriterFB::AdjustFinalSize() @@ -182,25 +177,16 @@ unsigned long long ullCIProcessedSize = m_spStats->GetCurrentItemProcessedSize(); if(ullCIProcessedSize < ullCITotalSize) { - file_size_t fsNewSize = 0; - eResult = m_spSrcFile->GetFileSize(fsNewSize); - if(eResult != TSubTaskBase::eSubResult_Continue) - return eResult; - - if(fsNewSize == m_spSrcFileInfo->GetLength64()) - throw TCoreException(eErr_InternalProblem, L"Read less data from file than it really contained. Possible destination file corruption.", LOCATION); - - if(fsNewSize != ullCIProcessedSize) + if(m_spSrcFileInfo->GetLength64() != ullCIProcessedSize) throw TCoreException(eErr_InternalProblem, L"Updated file size still does not match the count of data read. Possible destination file corruption.", LOCATION); - m_spStats->AdjustTotalSize(ullCITotalSize, fsNewSize); - m_spSrcFileInfo->SetLength64(fsNewSize); + m_spStats->AdjustTotalSize(ullCITotalSize, m_spSrcFileInfo->GetLength64()); } return eResult; } - TSubTaskBase::ESubOperationResult TOverlappedWriterFB::Start(bool bOnlyCreate) + TSubTaskBase::ESubOperationResult TOverlappedWriterFB::Start() { // open destination file, handle the failures and possibly existence of the destination file unsigned long long ullProcessedSize = m_spStats->GetCurrentItemProcessedSize(); @@ -240,7 +226,7 @@ ullSeekTo = 0; } - if(bOnlyCreate) + if(m_bOnlyCreate) { // we don't copy contents, but need to increase processed size m_spStats->AdjustProcessedSize(m_spStats->GetCurrentItemProcessedSize(), m_spSrcFileInfo->GetLength64()); @@ -267,6 +253,8 @@ // adjust the stats for the difference between what was already processed and what will now be considered processed m_spStats->AdjustProcessedSize(ullProcessedSize, fsMoveTo); + m_spDataRange->SetResumePosition(fsMoveTo); + // if the destination file already exists - truncate it to the current file position if(!bDstFileFreshlyCreated) { @@ -282,4 +270,14 @@ return eResult; } + + TOverlappedWriterPtr TOverlappedWriterFB::GetWriter() const + { + return m_spWriter; + } + + void TOverlappedWriterFB::SetReleaseMode() + { + m_bReleaseMode = true; + } } Index: src/libchcore/TOverlappedWriterFB.h =================================================================== diff -u -r8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TOverlappedWriterFB.h (.../TOverlappedWriterFB.h) (revision 8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e) +++ src/libchcore/TOverlappedWriterFB.h (.../TOverlappedWriterFB.h) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -21,40 +21,50 @@ #include "TOverlappedWriter.h" #include "TFilesystemFileFeedbackWrapper.h" +#include "TOverlappedProcessorRange.h" namespace chcore { class TOverlappedWriterFB { public: - TOverlappedWriterFB(const TFilesystemFileFeedbackWrapperPtr& spSrcFile, const TFilesystemFileFeedbackWrapperPtr& spDstFile, const TSubTaskStatsInfoPtr& spStats, + TOverlappedWriterFB(const IFilesystemPtr& spFilesystem, + const IFeedbackHandlerPtr& spFeedbackHandler, + TWorkerThreadController& rThreadController, + const TSubTaskStatsInfoPtr& spStats, const TFileInfoPtr& spSrcFileInfo, - const logger::TLogFileDataPtr& spLogFileData, const TOrderedBufferQueuePtr& spBuffersToWrite, - unsigned long long ullFilePos, const TBufferListPtr& spEmptyBuffers); + const TSmartPath& pathDst, + const logger::TLogFileDataPtr& spLogFileData, + const TOrderedBufferQueuePtr& spBuffersToWrite, + const TOverlappedProcessorRangePtr& spRange, + const TBufferListPtr& spEmptyBuffers, + bool bOnlyCreate, + bool bNoBuffering, + bool bProtectReadOnlyFiles); ~TOverlappedWriterFB(); - TSubTaskBase::ESubOperationResult Start(bool bOnlyCreate); + TSubTaskBase::ESubOperationResult Start(); - TOverlappedWriterPtr GetWriter() const { return m_spWriter; } + TOverlappedWriterPtr GetWriter() const; - void SetReleaseMode() { m_bReleaseMode = true; } + void SetReleaseMode(); TSubTaskBase::ESubOperationResult OnWritePossible(); TSubTaskBase::ESubOperationResult OnWriteFailed(); TSubTaskBase::ESubOperationResult OnWriteFinished(bool& bStopProcessing); private: - TSubTaskBase::ESubOperationResult AdjustProcessedSize(file_size_t fsWritten); + void AdjustProcessedSize(file_size_t fsWritten); TSubTaskBase::ESubOperationResult AdjustFinalSize(); private: TOverlappedWriterPtr m_spWriter; - TFilesystemFileFeedbackWrapperPtr m_spSrcFile; TFilesystemFileFeedbackWrapperPtr m_spDstFile; TSubTaskStatsInfoPtr m_spStats; TFileInfoPtr m_spSrcFileInfo; - TFileInfoPtr m_spDstFileInfo; + TOverlappedProcessorRangePtr m_spDataRange; bool m_bReleaseMode = false; + bool m_bOnlyCreate = false; }; using TOverlappedWriterFBPtr = std::shared_ptr; Index: src/libchcore/TReadBufferQueueWrapper.cpp =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TReadBufferQueueWrapper.cpp (.../TReadBufferQueueWrapper.cpp) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/TReadBufferQueueWrapper.cpp (.../TReadBufferQueueWrapper.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -165,4 +165,11 @@ { m_tRetryBuffers.ReleaseBuffers(m_spEmptyBuffers); } + + void TReadBufferQueueWrapper::UpdateProcessingRange(unsigned long long ullNewPosition) + { + if(!m_tRetryBuffers.empty()) + throw TCoreException(eErr_InvalidData, L"Cannot update processing range when processing already started", LOCATION); + m_ullNextReadPosition = ullNewPosition; + } } Index: src/libchcore/TReadBufferQueueWrapper.h =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TReadBufferQueueWrapper.h (.../TReadBufferQueueWrapper.h) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/TReadBufferQueueWrapper.h (.../TReadBufferQueueWrapper.h) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -49,6 +49,8 @@ HANDLE GetHasBuffersEvent() const; void ReleaseBuffers(); + void UpdateProcessingRange(unsigned long long ullNewPosition); + private: bool IsBufferReady() const; void UpdateHasBuffers(); Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -r8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 8aa9ecb7ccb06d721b9717a4bb664651b0b8b10e) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -130,7 +130,7 @@ unsigned long long ullNeededSize = rFilesCache.CalculateTotalSize() - rFilesCache.CalculatePartialSize(m_spSubTaskStats->GetCurrentIndex()); TSmartPath pathSingleSrc = spSrcPaths->GetAt(0)->GetSrcPath(); TSubTaskBase::ESubOperationResult eResult = tFilesystemFBWrapper.CheckForFreeSpaceFB(pathSingleSrc, pathDestination, ullNeededSize); - if(eResult != TSubTaskBase::eSubResult_Continue) + if(eResult != eSubResult_Continue) return eResult; // begin at index which wasn't processed previously @@ -174,7 +174,7 @@ { // log LOG_INFO(m_spLog) << _T("Kill request while processing file in ProcessFiles"); - return TSubTaskBase::eSubResult_KillRequest; + return eSubResult_KillRequest; } // next file to be copied @@ -211,7 +211,7 @@ if(spFileInfo->IsDirectory()) { eResult = tFilesystemFBWrapper.CreateDirectoryFB(ccp.pathDstFile); - if(eResult != TSubTaskBase::eSubResult_Continue) + if(eResult != eSubResult_Continue) return eResult; // new stats @@ -226,14 +226,12 @@ // copy data eResult = CustomCopyFileFB(spFeedbackHandler, &ccp); - if (eResult == TSubTaskBase::eSubResult_SkipFile) + if (eResult == eSubResult_SkipFile) { spFileInfo->MarkAsProcessed(false); AdjustProcessedSizeForSkip(spFileInfo); - - eResult = TSubTaskBase::eSubResult_Continue; } - else if(eResult != TSubTaskBase::eSubResult_Continue) + else if(eResult != eSubResult_Continue) return eResult; else spFileInfo->MarkAsProcessed(true); @@ -271,7 +269,7 @@ { // log LOG_INFO(m_spLog) << _T("Kill request while processing file in ProcessFiles"); - return TSubTaskBase::eSubResult_KillRequest; + return eSubResult_KillRequest; } TFileInfoPtr spFileInfo = rFilesCache.GetAt(fcAttrIndex - 1); @@ -292,7 +290,7 @@ // log LOG_INFO(m_spLog) << _T("Finished processing in ProcessFiles"); - return TSubTaskBase::eSubResult_Continue; + return eSubResult_Continue; } void TSubTaskCopyMove::GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const @@ -352,12 +350,6 @@ bool bNoBuffer = (GetTaskPropValue(rConfig) && pData->spSrcFile->GetLength64() >= GetTaskPropValue(rConfig)); - IFilesystemFilePtr fileSrc = spFilesystem->CreateFileObject(IFilesystemFile::eMode_Read, pData->spSrcFile->GetFullFilePath(), bNoBuffer, GetTaskPropValue(rConfig)); - IFilesystemFilePtr fileDst = spFilesystem->CreateFileObject(IFilesystemFile::eMode_Write, pData->pathDstFile, bNoBuffer, GetTaskPropValue(rConfig)); - - TFilesystemFileFeedbackWrapperPtr spSrcFileWrapper(std::make_shared(fileSrc, spFeedbackHandler, GetContext().GetLogFileData(), rThreadController, spFilesystem)); - TFilesystemFileFeedbackWrapperPtr spDstFileWrapper(std::make_shared(fileDst, spFeedbackHandler, GetContext().GetLogFileData(), rThreadController, spFilesystem)); - // recreate buffer if needed AdjustBufferIfNeeded(pData->spMemoryPool, pData->tBufferSizes); @@ -372,10 +364,10 @@ // by OpenSrcAndDstFilesFB() - that includes the no-buffering setting if required. unsigned long long ullNextReadPos = m_spSubTaskStats->GetCurrentItemProcessedSize(); - TOverlappedReaderWriterFB tReaderWriter(spSrcFileWrapper, pData->spSrcFile, spDstFileWrapper, m_spSubTaskStats, m_spLog->GetLogFileData(), - pData->spMemoryPool, ullNextReadPos, dwCurrentBufferSize); + TOverlappedReaderWriterFB tReaderWriter(spFilesystem, spFeedbackHandler, rThreadController, pData->spSrcFile, pData->pathDstFile, m_spSubTaskStats, m_spLog->GetLogFileData(), + pData->spMemoryPool, ullNextReadPos, dwCurrentBufferSize, bNoBuffer, GetTaskPropValue(rConfig), pData->bOnlyCreate); - ESubOperationResult eResult = tReaderWriter.Start(rThreadController.GetKillThreadHandle(), pData->bOnlyCreate); + ESubOperationResult eResult = tReaderWriter.Start(); return eResult; } Index: src/libchcore/Tests/OverlappedCallbacksTests.cpp =================================================================== diff -u -rdcbfdc95eedacd24d8b1d78fa507029ce12a5a63 -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/Tests/OverlappedCallbacksTests.cpp (.../OverlappedCallbacksTests.cpp) (revision dcbfdc95eedacd24d8b1d78fa507029ce12a5a63) +++ src/libchcore/Tests/OverlappedCallbacksTests.cpp (.../OverlappedCallbacksTests.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -14,7 +14,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared()); - TOverlappedReader queue(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader queue(spLogData, spBuffers->GetBufferList(), spRange, 4096); TOverlappedDataBuffer buffer(16384, &queue); buffer.InitForRead(0, 1024); @@ -34,7 +35,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared()); - TOverlappedReader queue(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader queue(spLogData, spBuffers->GetBufferList(), spRange, 4096); TOverlappedDataBuffer buffer(16384, &queue); buffer.InitForRead(0, 1024); @@ -56,7 +58,8 @@ TOverlappedMemoryPoolPtr spBuffers(std::make_shared()); TOrderedBufferQueuePtr spBuffersToWrite(std::make_shared(0)); - TOverlappedWriter queue(spLogData, spBuffersToWrite, 0, spBuffers->GetBufferList()); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedWriter queue(spLogData, spBuffersToWrite, spRange, spBuffers->GetBufferList()); TOverlappedDataBuffer buffer(16384, &queue); buffer.InitForRead(0, 1024); Index: src/libchcore/Tests/TOverlappedReaderTests.cpp =================================================================== diff -u -ra1f5b3d99f2f175b102d81379698ea1f08e42cce -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/Tests/TOverlappedReaderTests.cpp (.../TOverlappedReaderTests.cpp) (revision a1f5b3d99f2f175b102d81379698ea1f08e42cce) +++ src/libchcore/Tests/TOverlappedReaderTests.cpp (.../TOverlappedReaderTests.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -15,7 +15,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared()); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); EXPECT_EQ(nullptr, tReader.GetEmptyBuffer()); EXPECT_EQ(nullptr, tReader.GetFailedReadBuffer()); @@ -36,7 +37,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); EXPECT_SIGNALED(tReader.GetEventReadPossibleHandle()); EXPECT_TIMEOUT(tReader.GetEventReadFailedHandle()); @@ -57,7 +59,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); EXPECT_SIGNALED(tReader.GetEventReadPossibleHandle()); @@ -78,7 +81,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); TOverlappedDataBuffer* pBuffers[ 3 ] = { tReader.GetEmptyBuffer(), tReader.GetEmptyBuffer(), tReader.GetEmptyBuffer() }; @@ -99,7 +103,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); EXPECT_THROW(tReader.AddEmptyBuffer(nullptr), TCoreException); EXPECT_THROW(tReader.AddRetryBuffer(nullptr), TCoreException); @@ -111,7 +116,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); TOverlappedDataBuffer* pBuffer = tReader.GetEmptyBuffer(); tReader.AddFinishedReadBuffer(pBuffer); @@ -126,7 +132,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); TOverlappedDataBuffer* pBuffers[ 3 ] = { tReader.GetEmptyBuffer(), tReader.GetEmptyBuffer(), tReader.GetEmptyBuffer() }; tReader.AddFinishedReadBuffer(pBuffers[ 1 ]); @@ -144,7 +151,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); TOverlappedDataBuffer* pBuffers[ 3 ] = { tReader.GetEmptyBuffer(), tReader.GetEmptyBuffer(), tReader.GetEmptyBuffer() }; pBuffers[ 1 ]->SetLastPart(true); @@ -161,7 +169,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); EXPECT_THROW(tReader.AddFinishedReadBuffer(nullptr), TCoreException); } @@ -171,7 +180,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); TOverlappedDataBuffer* pBuffer = tReader.GetEmptyBuffer(); pBuffer->InitForRead(0, 1280); @@ -187,7 +197,8 @@ logger::TLogFileDataPtr spLogData(std::make_shared()); TOverlappedMemoryPoolPtr spBuffers(std::make_shared(3, 32768)); - TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), 0, 4096); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedReader tReader(spLogData, spBuffers->GetBufferList(), spRange, 4096); TOverlappedDataBuffer* pBuffers[ 3 ] = { tReader.GetEmptyBuffer(), tReader.GetEmptyBuffer(), tReader.GetEmptyBuffer() }; pBuffers[ 0 ]->InitForRead(0, 1000); Index: src/libchcore/Tests/TOverlappedWriterTests.cpp =================================================================== diff -u -rdcbfdc95eedacd24d8b1d78fa507029ce12a5a63 -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/Tests/TOverlappedWriterTests.cpp (.../TOverlappedWriterTests.cpp) (revision dcbfdc95eedacd24d8b1d78fa507029ce12a5a63) +++ src/libchcore/Tests/TOverlappedWriterTests.cpp (.../TOverlappedWriterTests.cpp) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -12,7 +12,8 @@ TBufferListPtr spEmptyBuffers(std::make_shared()); TOrderedBufferQueuePtr spQueue(std::make_shared(0)); - TOverlappedWriter tWriter(spLogData, spQueue, 0, spEmptyBuffers); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedWriter tWriter(spLogData, spQueue, spRange, spEmptyBuffers); EXPECT_EQ(nullptr, tWriter.GetWriteBuffer()); EXPECT_EQ(nullptr, tWriter.GetFailedWriteBuffer()); @@ -33,7 +34,8 @@ TBufferListPtr spEmptyBuffers(std::make_shared()); TOrderedBufferQueuePtr spQueue(std::make_shared(0)); - TOverlappedWriter tWriter(spLogData, spQueue, 0, spEmptyBuffers); + TOverlappedProcessorRangePtr spRange(std::make_shared(0)); + TOverlappedWriter tWriter(spLogData, spQueue, spRange, spEmptyBuffers); EXPECT_TIMEOUT(tWriter.GetEventWritePossibleHandle()); EXPECT_TIMEOUT(tWriter.GetEventWriteFailedHandle()); Index: src/libchcore/libchcore.vc140.vcxproj =================================================================== diff -u -r2a34de9ddfcfb4a1ed4c61ece641d37b91c23b6b -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision 2a34de9ddfcfb4a1ed4c61ece641d37b91c23b6b) +++ src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -522,6 +522,7 @@ + @@ -830,6 +831,7 @@ + Index: src/libchcore/libchcore.vc140.vcxproj.filters =================================================================== diff -u -rc0d9a798f9fbbeda239b84721ed864f9727e1ddc -rf1d25f23712f5de7459f690ab51b2640d0f81b91 --- src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision c0d9a798f9fbbeda239b84721ed864f9727e1ddc) +++ src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision f1d25f23712f5de7459f690ab51b2640d0f81b91) @@ -531,6 +531,9 @@ Source Files\Feedback Wrappers + + Source Files\Tools\Data Buffer\ReaderWriter + @@ -977,6 +980,9 @@ Source Files\Feedback Wrappers + + Source Files\Tools\Data Buffer\ReaderWriter +