From d2854834e18443876c8f75e0a7f3b88d1d549fc4 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:15:39 +0200 Subject: 4.2 --- lib/parallel_scan.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'lib/parallel_scan.cpp') diff --git a/lib/parallel_scan.cpp b/lib/parallel_scan.cpp index 29d87ee7..96b167b8 100644 --- a/lib/parallel_scan.cpp +++ b/lib/parallel_scan.cpp @@ -171,7 +171,7 @@ std::vector> separateByDistinctDisk(const std::set BasicWString; //thread safe string class for UI texts -class AsyncCallback +class AsyncCallback //actor pattern { public: AsyncCallback() : @@ -207,7 +207,7 @@ public: boost::lock_guard dummy(lockErrorMsg); if (!errorMsg.empty() && !errorResponse.get()) { - FillBufferCallback::HandleError rv = callback.reportError(cvrtString(errorMsg)); //throw! + FillBufferCallback::HandleError rv = callback.reportError(copyStringTo(errorMsg)); //throw! errorResponse.reset(new FillBufferCallback::HandleError(rv)); //dummy.unlock(); @@ -244,12 +244,12 @@ public: if (!currentFile.empty()) filename = utf8CvrtTo(currentFile); else if (!currentStatus.empty()) - statusMsg = cvrtString(currentStatus); + statusMsg = copyStringTo(currentStatus); } if (!filename.empty()) { - std::wstring statusText = cvrtString(textScanning); + std::wstring statusText = copyStringTo(textScanning); const long activeCount = activeWorker; if (activeCount >= 2) { @@ -293,8 +293,6 @@ private: }; //------------------------------------------------------------------------------------------------- -class DirCallback; - struct TraverserShared { public: @@ -309,9 +307,6 @@ public: acb_(acb), threadID_(threadID) {} - typedef std::shared_ptr CallbackPointer; - std::vector callBackBox; //collection of callback pointers to handle ownership - const SymLinkHandling handleSymlinks_; const HardFilter::FilterRef filterInstance; //always bound! @@ -332,10 +327,11 @@ public: relNameParentPf_(relNameParentPf), output_(output) {} - virtual void onFile (const Zchar* shortName, const Zstring& fullName, const FileInfo& details); - virtual void onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details); - virtual ReturnValDir onDir (const Zchar* shortName, const Zstring& fullName); - virtual HandleError onError (const std::wstring& errorText); + virtual std::shared_ptr + onDir (const Zchar* shortName, const Zstring& fullName); + virtual void onFile (const Zchar* shortName, const Zstring& fullName, const FileInfo& details); + virtual void onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details); + virtual HandleError onError (const std::wstring& errorText); private: TraverserShared& cfg; @@ -405,7 +401,7 @@ void DirCallback::onSymlink(const Zchar* shortName, const Zstring& fullName, con } -TraverseCallback::ReturnValDir DirCallback::onDir(const Zchar* shortName, const Zstring& fullName) +std::shared_ptr DirCallback::onDir(const Zchar* shortName, const Zstring& fullName) { boost::this_thread::interruption_point(); @@ -419,16 +415,14 @@ TraverseCallback::ReturnValDir DirCallback::onDir(const Zchar* shortName, const bool subObjMightMatch = true; const bool passFilter = cfg.filterInstance->passDirFilter(relName, &subObjMightMatch); if (!passFilter && !subObjMightMatch) - return Int2Type(); //do NOT traverse subdirs + return nullptr; //do NOT traverse subdirs //else: attention! ensure directory filtering is applied later to exclude actually filtered directories DirContainer& subDir = output_.addSubDir(shortName); if (passFilter) cfg.acb_.incItemsScanned(); //add 1 element to the progress indicator - TraverserShared::CallbackPointer subDirCallback = std::make_shared(cfg, relName + FILE_NAME_SEPARATOR, subDir); - cfg.callBackBox.push_back(subDirCallback); //handle lifetime - return ReturnValDir(Int2Type(), *subDirCallback); + return std::make_shared(cfg, relName + FILE_NAME_SEPARATOR, subDir); } -- cgit