1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

No boost condition (#2822)

This patch replaces boost primitives with stdlib counterparts.
This commit is contained in:
Leonid Fedorov
2023-04-22 00:42:45 +03:00
committed by GitHub
parent 3ce19abdae
commit f916e64927
245 changed files with 1261 additions and 2007 deletions

View File

@ -29,7 +29,8 @@
#include <algorithm>
#include <unistd.h>
using namespace std;
#include <boost/thread/mutex.hpp>
#include <map>
#include <mutex>
#include <boost/scoped_ptr.hpp>
using namespace boost;
@ -58,13 +59,13 @@ namespace WriteEngine
{
BRMWrapper* volatile BRMWrapper::m_instance = NULL;
boost::thread_specific_ptr<int> BRMWrapper::m_ThreadDataPtr;
boost::mutex BRMWrapper::m_instanceCreateMutex;
std::mutex BRMWrapper::m_instanceCreateMutex;
bool BRMWrapper::m_useVb = true;
OID BRMWrapper::m_curVBOid = INVALID_NUM;
IDBDataFile* BRMWrapper::m_curVBFile = NULL;
boost::mutex vbFileLock;
std::mutex vbFileLock;
struct fileInfoCompare // lt operator
{
bool operator()(const File& lhs, const File& rhs) const
@ -300,7 +301,7 @@ BRMWrapper* BRMWrapper::getInstance()
{
if (m_instance == 0)
{
boost::mutex::scoped_lock lock(m_instanceCreateMutex);
std::unique_lock lock(m_instanceCreateMutex);
if (m_instance == 0)
{
@ -1638,7 +1639,7 @@ int BRMWrapper::writeVB(IDBDataFile* pSourceFile, const VER_t transID, const OID
fileInfo.fSegment = 0;
// fileInfo.fDbRoot = (freeList[0].vbOID % rootCnt) + 1;
fileInfo.fDbRoot = dbRoot;
boost::mutex::scoped_lock lk(vbFileLock);
std::unique_lock lk(vbFileLock);
pTargetFile = openFile(fileInfo, "r+b", true);
if (pTargetFile == NULL)

View File

@ -464,7 +464,7 @@ class BRMWrapper : public WEObj
static BRMWrapper* volatile m_instance;
static boost::thread_specific_ptr<int> m_ThreadDataPtr;
static boost::mutex m_instanceCreateMutex;
static std::mutex m_instanceCreateMutex;
EXPORT static bool m_useVb;

View File

@ -59,9 +59,9 @@ string Config::m_bulkRoot;
unsigned long Config::fDBRootChangeCount = 0;
time_t Config::fCacheTime = 0;
boost::mutex Config::fCacheLock;
std::mutex Config::fCacheLock;
#ifdef SHARED_NOTHING_DEMO_2
boost::mutex Config::m_bulkRoot_lk;
std::mutex Config::m_bulkRoot_lk;
#endif
int Config::m_WaitPeriod = DEFAULT_WAIT_PERIOD;
unsigned Config::m_FilesPerColumnPartition = DEFAULT_FILES_PER_COLUMN_PARTITION;
@ -86,7 +86,7 @@ string Config::m_VersionBufferDir;
******************************************************************************/
void Config::initConfigCache()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
}
@ -330,7 +330,7 @@ void Config::checkReload()
******************************************************************************/
size_t Config::DBRootCount()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_dbRootCount;
@ -346,7 +346,7 @@ size_t Config::DBRootCount()
******************************************************************************/
std::string Config::getDBRootByIdx(unsigned idx)
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
if (idx >= m_dbRootPath.size())
@ -368,7 +368,7 @@ std::string Config::getDBRootByIdx(unsigned idx)
******************************************************************************/
void Config::getDBRootPathList(std::vector<std::string>& dbRootPathList)
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
dbRootPathList.clear();
@ -385,7 +385,7 @@ void Config::getDBRootPathList(std::vector<std::string>& dbRootPathList)
******************************************************************************/
std::string Config::getDBRootByNum(unsigned num)
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
Config::intstrmap_t::const_iterator iter = m_dbRootPathMap.find(num);
@ -409,7 +409,7 @@ std::string Config::getDBRootByNum(unsigned num)
******************************************************************************/
void Config::getRootIdList(std::vector<uint16_t>& rootIds)
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
rootIds = m_dbRootId;
@ -425,7 +425,7 @@ void Config::getRootIdList(std::vector<uint16_t>& rootIds)
******************************************************************************/
std::string Config::getBulkRoot()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_bulkRoot;
@ -435,7 +435,7 @@ std::string Config::getBulkRoot()
void Config::getSharedNothingRoot(char* ret)
{
string root;
boost::mutex::scoped_lock lk(m_bulkRoot_lk);
std::unique_lock lk(m_bulkRoot_lk);
root = config::Config::makeConfig()->getConfig("WriteEngine", "SharedNothingRoot");
strncpy(ret, root.c_str(), FILE_NAME_SIZE);
@ -452,7 +452,7 @@ void Config::getSharedNothingRoot(char* ret)
******************************************************************************/
int Config::getWaitPeriod()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_WaitPeriod;
@ -468,7 +468,7 @@ int Config::getWaitPeriod()
******************************************************************************/
unsigned Config::getFilesPerColumnPartition()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_FilesPerColumnPartition;
@ -484,7 +484,7 @@ unsigned Config::getFilesPerColumnPartition()
******************************************************************************/
unsigned Config::getExtentsPerSegmentFile()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_ExtentsPerSegmentFile;
@ -507,7 +507,7 @@ unsigned Config::getExtentsPerSegmentFile()
******************************************************************************/
int Config::getBulkProcessPriority()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_BulkProcessPriority;
@ -521,7 +521,7 @@ int Config::getBulkProcessPriority()
******************************************************************************/
std::string Config::getBulkRollbackDir()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_BulkRollbackDir;
@ -535,7 +535,7 @@ std::string Config::getBulkRollbackDir()
******************************************************************************/
bool Config::getFastDelete()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_FastDelete;
@ -549,7 +549,7 @@ bool Config::getFastDelete()
******************************************************************************/
unsigned Config::getMaxFileSystemDiskUsage()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_MaxFileSystemDiskUsage;
@ -564,7 +564,7 @@ unsigned Config::getMaxFileSystemDiskUsage()
******************************************************************************/
unsigned Config::getNumCompressedPadBlks()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_NumCompressedPadBlks;
@ -578,7 +578,7 @@ unsigned Config::getNumCompressedPadBlks()
******************************************************************************/
bool Config::getParentOAMModuleFlag()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_ParentOAMModuleFlag;
@ -592,7 +592,7 @@ bool Config::getParentOAMModuleFlag()
******************************************************************************/
std::string Config::getLocalModuleType()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_LocalModuleType;
@ -606,7 +606,7 @@ std::string Config::getLocalModuleType()
******************************************************************************/
uint16_t Config::getLocalModuleID()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_LocalModuleID;
@ -622,7 +622,7 @@ uint16_t Config::getLocalModuleID()
******************************************************************************/
std::string Config::getVBRoot()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
checkReload();
return m_VersionBufferDir;
@ -639,7 +639,7 @@ std::string Config::getVBRoot()
******************************************************************************/
bool Config::hasLocalDBRootListChanged()
{
boost::mutex::scoped_lock lk(fCacheLock);
std::unique_lock lk(fCacheLock);
if (fDBRootChangeCount > 0)
{

View File

@ -182,9 +182,9 @@ class Config
static std::string m_bulkRoot; // root path for bulk operation
static unsigned long fDBRootChangeCount; // track recent DBRoot changes
static time_t fCacheTime; // timestamp associated w/cache
static boost::mutex fCacheLock; // mutex for m_dbRoot sync
static std::mutex fCacheLock; // mutex for m_dbRoot sync
#ifdef SHARED_NOTHING_DEMO_2
static boost::mutex m_bulkRoot_lk; // mutex for m_bulkRoot sync
static std::mutex m_bulkRoot_lk; // mutex for m_bulkRoot sync
#endif
static int m_WaitPeriod; // secs to wait for transaction
static unsigned m_FilesPerColumnPartition; //# seg files per partition

View File

@ -474,7 +474,7 @@ void DBRootExtentTracker::logFirstDBRootSelection() const
bool DBRootExtentTracker::nextSegFile(uint16_t& dbRoot, uint32_t& partition, uint16_t& segment, HWM& localHwm,
BRM::LBID_t& startLbid)
{
boost::mutex::scoped_lock lock(fDBRootExtTrkMutex);
std::unique_lock lock(fDBRootExtTrkMutex);
fCurrentDBRootIdx++;
@ -515,7 +515,7 @@ bool DBRootExtentTracker::nextSegFile(uint16_t& dbRoot, uint32_t& partition, uin
const std::vector<DBRootExtentInfo>& DBRootExtentTracker::getDBRootExtentList()
{
boost::mutex::scoped_lock lock(fDBRootExtTrkMutex);
std::unique_lock lock(fDBRootExtTrkMutex);
return fDBRootExtentList;
}

View File

@ -34,7 +34,8 @@
#pragma once
#include <boost/thread/mutex.hpp>
#include <map>
#include <mutex>
#include <vector>
#include "we_type.h"
@ -184,7 +185,7 @@ class DBRootExtentTracker
*/
inline int getCurrentDBRootIdx()
{
boost::mutex::scoped_lock lock(fDBRootExtTrkMutex);
std::unique_lock lock(fDBRootExtTrkMutex);
return fCurrentDBRootIdx;
}
@ -199,7 +200,7 @@ class DBRootExtentTracker
OID fOID; // applicable colunn OID
long long fBlksPerExtent; // blocks per extent for fOID
Log* fLog; // logger
boost::mutex fDBRootExtTrkMutex; // mutex to access fDBRootExtentList
std::mutex fDBRootExtTrkMutex; // mutex to access fDBRootExtentList
int fCurrentDBRootIdx; // Index into fDBRootExtentList,
// DBRoot where current extent is
// being added

View File

@ -58,9 +58,9 @@ using namespace idbdatafile;
namespace WriteEngine
{
/*static*/ boost::mutex FileOp::m_createDbRootMutexes;
/*static*/ boost::mutex FileOp::m_mkdirMutex;
/*static*/ std::map<int, boost::mutex> FileOp::m_DbRootAddExtentMutexes;
/*static*/ std::mutex FileOp::m_createDbRootMutexes;
/*static*/ std::mutex FileOp::m_mkdirMutex;
/*static*/ std::map<int, std::mutex> FileOp::m_DbRootAddExtentMutexes;
// in 1 call to fwrite(), during initialization
// StopWatch timer;
@ -116,7 +116,7 @@ void FileOp::closeFile(IDBDataFile* pFile) const
***********************************************************/
int FileOp::createDir(const char* dirName, mode_t mode) const
{
boost::mutex::scoped_lock lk(m_mkdirMutex);
std::unique_lock lk(m_mkdirMutex);
int rc = IDBPolicy::mkdir(dirName);
if (rc != 0)
@ -993,7 +993,7 @@ int FileOp::initColumnExtent(IDBDataFile* pFile, uint16_t dbRoot, int nBlocks, c
Stats::startParseEvent(WE_STATS_WAIT_TO_CREATE_COL_EXTENT);
#endif
boost::mutex::scoped_lock lk(m_DbRootAddExtentMutexes[dbRoot]);
std::unique_lock lk(m_DbRootAddExtentMutexes[dbRoot]);
#ifdef PROFILE
if (bExpandExtent)
@ -1714,7 +1714,7 @@ int FileOp::initDctnryExtent(IDBDataFile* pFile, uint16_t dbRoot, int nBlocks, u
Stats::startParseEvent(WE_STATS_WAIT_TO_CREATE_DCT_EXTENT);
#endif
boost::mutex::scoped_lock lk(m_DbRootAddExtentMutexes[dbRoot]);
std::unique_lock lk(m_DbRootAddExtentMutexes[dbRoot]);
#ifdef PROFILE
if (bExpandExtent)
@ -1800,7 +1800,7 @@ int FileOp::initDctnryExtent(IDBDataFile* pFile, uint16_t dbRoot, int nBlocks, u
/* static */
void FileOp::initDbRootExtentMutexes()
{
boost::mutex::scoped_lock lk(m_createDbRootMutexes);
std::unique_lock lk(m_createDbRootMutexes);
if (m_DbRootAddExtentMutexes.size() == 0)
{

View File

@ -453,13 +453,13 @@ class FileOp : public BlockOp, public WeUIDGID
bool m_isFix;
// protect creation of m_DbRootAddExtentMutexes
static boost::mutex m_createDbRootMutexes;
static std::mutex m_createDbRootMutexes;
// Mutexes used to serialize extent creation within each DBRoot
static std::map<int, boost::mutex> m_DbRootAddExtentMutexes;
static std::map<int, std::mutex> m_DbRootAddExtentMutexes;
// protect race condition in creating directories
static boost::mutex m_mkdirMutex;
static std::mutex m_mkdirMutex;
char* m_buffer; // buffer used with setvbuf()
};

View File

@ -108,7 +108,7 @@ void Log::logMsg(const char* msg, int code, MsgLevel level)
{
// log to log file and error log file within scope of mutex lock.
// logSyslog uses SimpleSyslog which has it's own lock.
boost::mutex::scoped_lock lk(m_WriteLockMutex);
std::unique_lock lk(m_WriteLockMutex);
m_errLogFile << oss.str() << std::endl;
m_logFile << oss.str() << std::endl;
@ -128,7 +128,7 @@ void Log::logMsg(const char* msg, int code, MsgLevel level)
if ((level != MSGLVL_INFO2) || (m_bConsoleOutput))
formatMsg(msg, level, oss2);
boost::mutex::scoped_lock lk(m_WriteLockMutex);
std::unique_lock lk(m_WriteLockMutex);
m_logFile << oss.str() << std::endl;

View File

@ -99,7 +99,7 @@ class Log : public WEObj
std::ofstream m_logFile; // log file stream
std::ofstream m_errLogFile; // error log file stream
boost::mutex m_WriteLockMutex; // logging mutex
std::mutex m_WriteLockMutex; // logging mutex
};
} // namespace WriteEngine

View File

@ -663,7 +663,7 @@ bool RBMetaWriter::backupDctnryHWMChunk(OID dctnryOID, uint16_t dbRoot, uint32_t
{
// Use scoped lock to perform "find"
boost::mutex::scoped_lock lock(fRBChunkDctnryMutex);
std::unique_lock lock(fRBChunkDctnryMutex);
if ((fLog) && (fLog->isDebug(DEBUG_1)))
printDctnryChunkList(chunkInfo, "when searching ");
@ -705,7 +705,7 @@ bool RBMetaWriter::backupDctnryHWMChunk(OID dctnryOID, uint16_t dbRoot, uint32_t
{
// Use scoped lock to perform "erase"
boost::mutex::scoped_lock lock(fRBChunkDctnryMutex);
std::unique_lock lock(fRBChunkDctnryMutex);
fRBChunkDctnrySet.erase(chunkInfoFound);
if ((fLog) && (fLog->isDebug(DEBUG_1)))

View File

@ -34,7 +34,8 @@
#include <set>
#include <map>
#include <vector>
#include <boost/thread/mutex.hpp>
#include <map>
#include <mutex>
#include "we_type.h"
#include "brmtypes.h"
@ -314,7 +315,7 @@ class RBMetaWriter : public WeUIDGID
Log* fLog; // import log file
bool fCreatedSubDir; // has subdir path been created
RBChunkSet fRBChunkDctnrySet; // Dctnry HWM chunk info
boost::mutex fRBChunkDctnryMutex; // Mutex lock for RBChunkSet
std::mutex fRBChunkDctnryMutex; // Mutex lock for RBChunkSet
OID fTableOID; // OID of relevant table
std::string fTableName; // Name of relevant table
};

View File

@ -69,7 +69,7 @@ void SimpleSysLog::logMsg(const logging::Message::Args& msgArgs, logging::LOG_TY
logging::Message m(msgId);
m.format(msgArgs);
boost::mutex::scoped_lock lk(fWriteLockMutex);
std::unique_lock lk(fWriteLockMutex);
switch (logType)
{

View File

@ -66,7 +66,7 @@ class SimpleSysLog
static SimpleSysLog* fSysLogger;
logging::LoggingID fLoggingID;
boost::mutex fWriteLockMutex; // logging mutex
std::mutex fWriteLockMutex; // logging mutex
};
#undef EXPORT

View File

@ -29,8 +29,8 @@ namespace WriteEngine
{
#ifdef PROFILE
/* static */ bool Stats::fProfiling = false;
/* static */ boost::mutex Stats::fRegisterReaderMutex;
/* static */ boost::mutex Stats::fRegisterParseMutex;
/* static */ std::mutex Stats::fRegisterReaderMutex;
/* static */ std::mutex Stats::fRegisterParseMutex;
/* static */ std::vector<pthread_t> Stats::fReadProfThreads;
/* static */ std::vector<pthread_t> Stats::fParseProfThreads;
/* static */ std::vector<logging::StopWatch> Stats::fReadStopWatch;
@ -111,7 +111,7 @@ void Stats::enableProfiling(int nReadThreads, int nParseThreads)
***********************************************************/
void Stats::registerReadProfThread()
{
boost::mutex::scoped_lock lk(fRegisterReaderMutex);
std::unique_lock lk(fRegisterReaderMutex);
fReadProfThreads.push_back(pthread_self());
logging::StopWatch readStopWatch;
@ -128,7 +128,7 @@ void Stats::registerReadProfThread()
***********************************************************/
void Stats::registerParseProfThread()
{
boost::mutex::scoped_lock lk(fRegisterParseMutex);
std::unique_lock lk(fRegisterParseMutex);
fParseProfThreads.push_back(pthread_self());
logging::StopWatch parseStopWatch;

View File

@ -24,7 +24,8 @@
#pragma once
#include <we_obj.h>
#ifdef PROFILE
#include <boost/thread/mutex.hpp>
#include <map>
#include <mutex>
#include "stopwatch.h"
#endif
@ -159,10 +160,10 @@ class Stats
static bool fProfiling; // Is profiling enabled
// Protect concurrent addition of Readers
static boost::mutex fRegisterReaderMutex;
static std::mutex fRegisterReaderMutex;
// Protect concurrent addition of Parsers
static boost::mutex fRegisterParseMutex;
static std::mutex fRegisterParseMutex;
// Read threads to be profiled
static std::vector<pthread_t> fReadProfThreads;