From 47f4d0b7e921b0fad2d2f58f0c0263a36849fefe Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 25 Feb 2012 21:33:18 +0100 Subject: [PATCH] Changed: Replaced some mutexes. --HG-- branch : build_pipeline_v3 --- .../pipeline/pipeline_service/database_status.cpp | 14 +++++++------- .../pipeline/pipeline_service/database_status.h | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/code/nel/tools/pipeline/pipeline_service/database_status.cpp b/code/nel/tools/pipeline/pipeline_service/database_status.cpp index 058e47bd4..ce8f54634 100644 --- a/code/nel/tools/pipeline/pipeline_service/database_status.cpp +++ b/code/nel/tools/pipeline/pipeline_service/database_status.cpp @@ -133,7 +133,7 @@ bool CDatabaseStatus::getFileStatus(CFileStatus &fileStatus, const std::string & bool seemsValid = false; std::string stdPath = unMacroPath(filePath); std::string statusPath = getStatusFilePath(filePath); - m_StatusMutex.enterReader(); + m_StatusMutex.lock_shared(); if (CFile::fileExists(statusPath)) { CIFile ifs(statusPath, false); @@ -153,7 +153,7 @@ bool CDatabaseStatus::getFileStatus(CFileStatus &fileStatus, const std::string & fileStatus.LastUpdate = 0; fileStatus.CRC32 = 0; } - m_StatusMutex.leaveReader(); + m_StatusMutex.unlock_shared(); return seemsValid; } @@ -167,7 +167,7 @@ public: TFileStatusCallback Callback; std::string FilePath; // Standardized! - CReaderWriter *StatusMutex; + boost::shared_mutex *StatusMutex; virtual void run() { @@ -178,7 +178,7 @@ public: uint32 time = CTime::getSecondsSince1970(); uint32 fmdt = CFile::getFileModificationDate(FilePath); std::string statusPath = getStatusFilePath(FilePath); // g_PipelineDirectory + PIPELINE_DATABASE_STATUS_SUBDIR + dropDatabaseDirectory(FilePath) + ".status"; - StatusMutex->enterReader(); + StatusMutex->lock_shared(); if (CFile::fileExists(statusPath)) { CIFile ifs(statusPath, false); @@ -191,7 +191,7 @@ public: fs.LastChangedReference = 0; fs.LastFileSizeReference = ~0; } - StatusMutex->leaveReader(); + StatusMutex->unlock_shared(); if (fs.LastChangedReference == fmdt && fs.LastFileSizeReference == CFile::getFileSize(FilePath)) { nlinfo("Skipping already updated status, may have been queued twice (%s)", FilePath.c_str()); @@ -228,14 +228,14 @@ public: fs.LastFileSizeReference = fisz; } - StatusMutex->enterWriter(); + StatusMutex->lock(); { COFile ofs(statusPath, false, false, true); fs.serial(ofs); ofs.flush(); ofs.close(); } - StatusMutex->leaveWriter(); + StatusMutex->unlock(); } Callback(FilePath, fs, true); } diff --git a/code/nel/tools/pipeline/pipeline_service/database_status.h b/code/nel/tools/pipeline/pipeline_service/database_status.h index 1a8eee623..981fdcf48 100644 --- a/code/nel/tools/pipeline/pipeline_service/database_status.h +++ b/code/nel/tools/pipeline/pipeline_service/database_status.h @@ -32,9 +32,10 @@ // STL includes #include #include +#include +#include // NeL includes -#include #include #include @@ -95,8 +96,8 @@ typedef CCallback