1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

Revert "No boost condition (#2822)" (#2828)

This reverts commit f916e64927.
This commit is contained in:
Roman Nozdrin
2023-04-22 13:49:50 +01:00
committed by GitHub
parent f916e64927
commit 4fe9cd64a3
245 changed files with 2007 additions and 1261 deletions

View File

@@ -24,9 +24,8 @@
#include <sstream>
#include <stdexcept>
#include <boost/thread/thread.hpp>
#include <map>
#include <mutex>
#include <condition_variable>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <atomic>

View File

@@ -72,7 +72,7 @@ PriorityThreadPool::~PriorityThreadPool()
void PriorityThreadPool::addJob(const Job& job, bool useLock)
{
boost::thread* newThread;
std::unique_lock lk(mutex, std::defer_lock);
boost::mutex::scoped_lock lk(mutex, boost::defer_lock_t());
if (useLock)
lk.lock();
@@ -129,7 +129,7 @@ void PriorityThreadPool::removeJobs(uint32_t id)
{
list<Job>::iterator it;
std::unique_lock lk(mutex);
boost::mutex::scoped_lock lk(mutex);
for (uint32_t i = 0; i < _COUNT; i++)
for (it = jobQueues[i].begin(); it != jobQueues[i].end();)
@@ -169,7 +169,7 @@ void PriorityThreadPool::threadFcn(const Priority preferredQueue) throw()
{
while (!_stop)
{
std::unique_lock lk(mutex);
boost::mutex::scoped_lock lk(mutex);
queue = pickAQueue(preferredQueue);

View File

@@ -30,9 +30,8 @@
#include <sstream>
#include <stdexcept>
#include <boost/thread/thread.hpp>
#include <map>
#include <mutex>
#include <condition_variable>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <atomic>
@@ -114,7 +113,7 @@ class PriorityThreadPool
{
return blockedThreads;
}
protected:
private:
struct ThreadHelper
@@ -141,8 +140,8 @@ class PriorityThreadPool
std::list<Job> jobQueues[3]; // higher indexes = higher priority
uint32_t threadCounts[3];
uint32_t defaultThreadCounts[3];
std::mutex mutex;
std::condition_variable newJob;
boost::mutex mutex;
boost::condition newJob;
boost::thread_group threads;
bool _stop;
uint32_t weightPerRun;

View File

@@ -34,7 +34,7 @@ using namespace std;
#include "threadpool.h"
int thecount = 0;
std::mutex mutex;
boost::mutex mutex;
class ThreadPoolTestSuite : public CppUnit::TestFixture
{
@@ -56,7 +56,7 @@ class ThreadPoolTestSuite : public CppUnit::TestFixture
fData++;
}
std::unique_lock lock(mutex);
boost::mutex::scoped_lock lock(mutex);
std::cout << "count = " << ++thecount << ' ' << fData << std::endl;
}

View File

@@ -32,7 +32,6 @@ using namespace logging;
#include "threadnaming.h"
#include <iomanip>
#include <sstream>
#include <chrono>
#include "boost/date_time/posix_time/posix_time_types.hpp"
#include "mcsconfig.h"
@@ -53,7 +52,7 @@ ThreadPool::~ThreadPool() throw()
{
try
{
std::unique_lock initLock(fInitMutex);
boost::mutex::scoped_lock initLock(fInitMutex);
stop();
}
catch (...)
@@ -63,7 +62,7 @@ ThreadPool::~ThreadPool() throw()
void ThreadPool::init()
{
std::unique_lock initLock(fInitMutex);
boost::mutex::scoped_lock initLock(fInitMutex);
fThreadCount = 0;
fGeneralErrors = 0;
fFunctorErrors = 0;
@@ -78,20 +77,20 @@ void ThreadPool::init()
void ThreadPool::setQueueSize(size_t queueSize)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
fQueueSize = queueSize;
}
void ThreadPool::pruneThread()
{
utils::setThreadName("pruneThread");
std::unique_lock<std::mutex> lock2(fPruneMutex);
boost::unique_lock<boost::mutex> lock2(fPruneMutex);
while (true)
{
if (fStop)
return;
if (fPruneThreadEnd.wait_for(lock2, std::chrono::minutes{1}) == std::cv_status::timeout)
if (fPruneThreadEnd.wait_for(lock2, boost::chrono::minutes{1}) == boost::cv_status::timeout)
{
while (!fPruneThreads.empty())
{
@@ -120,13 +119,13 @@ void ThreadPool::pruneThread()
void ThreadPool::setMaxThreads(size_t maxThreads)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
fMaxThreads = maxThreads;
}
void ThreadPool::stop()
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
if (fStop)
return; // Was stopped earlier
fStop = true;
@@ -141,7 +140,7 @@ void ThreadPool::stop()
void ThreadPool::wait()
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
while (waitingFunctorsSize > 0)
{
@@ -152,7 +151,7 @@ void ThreadPool::wait()
void ThreadPool::join(uint64_t thrHandle)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
while (waitingFunctorsSize > 0)
{
@@ -182,7 +181,7 @@ void ThreadPool::join(uint64_t thrHandle)
void ThreadPool::join(std::vector<uint64_t>& thrHandle)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
while (waitingFunctorsSize > 0)
{
@@ -223,7 +222,7 @@ void ThreadPool::join(std::vector<uint64_t>& thrHandle)
uint64_t ThreadPool::invoke(const Functor_T& threadfunc)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
uint64_t thrHandle = 0;
for (;;)
@@ -320,7 +319,7 @@ void ThreadPool::beginThread() throw()
utils::setThreadName("Idle");
try
{
std::unique_lock<std::mutex> lock1(fMutex);
boost::unique_lock<boost::mutex> lock1(fMutex);
for (;;)
{
@@ -339,11 +338,11 @@ void ThreadPool::beginThread() throw()
else
{
// Wait no more than 10 minutes
if (fNeedThread.wait_for(lock1, std::chrono::minutes{10}) == std::cv_status::timeout)
if (fNeedThread.wait_for(lock1, boost::chrono::minutes{10}) == boost::cv_status::timeout)
{
if (fThreadCount > fMaxThreads)
{
std::unique_lock lock2(fPruneMutex);
boost::mutex::scoped_lock lock2(fPruneMutex);
fPruneThreads.push(boost::this_thread::get_id());
--fThreadCount;
return;

View File

@@ -37,9 +37,8 @@
#include <stack>
#include <stdint.h>
#include <boost/thread/thread.hpp>
#include <map>
#include <mutex>
#include <condition_variable>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/thread/locks.hpp>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
@@ -346,9 +345,9 @@ class ThreadPool
Container_T::iterator fNextFunctor;
uint32_t fIssued;
std::mutex fMutex;
std::condition_variable fThreadAvailable; // triggered when a thread is available
std::condition_variable fNeedThread; // triggered when a thread is needed
boost::mutex fMutex;
boost::condition_variable fThreadAvailable; // triggered when a thread is available
boost::condition_variable fNeedThread; // triggered when a thread is needed
ThreadPoolGroup fThreads;
bool fStop;
@@ -359,9 +358,9 @@ class ThreadPool
std::string fName; // Optional to add a name to the pool for debugging.
bool fDebug;
std::mutex fInitMutex;
std::mutex fPruneMutex;
std::condition_variable fPruneThreadEnd;
boost::mutex fInitMutex;
boost::mutex fPruneMutex;
boost::condition_variable fPruneThreadEnd;
boost::thread* fPruneThread;
std::stack<boost::thread::id> fPruneThreads; // A list of stale thread IDs to be joined
};

View File

@@ -30,7 +30,7 @@ using namespace std;
#include "threadpool.h"
int64_t thecount = 0;
std::mutex mutex;
boost::mutex mutex;
const string timeNow()
{
@@ -68,7 +68,7 @@ struct foo
// simulate some work
fData++;
std::unique_lock lock(mutex);
boost::mutex::scoped_lock lock(mutex);
std::cout << "foo thd = " << fThd << " start " << start << " fin " << timeNow() << std::endl;
}
@@ -123,7 +123,7 @@ int main(int argc, char** argv)
}
}
std::unique_lock lock(mutex);
boost::mutex::scoped_lock lock(mutex);
}
// Wait until all of the queued up and in-progress work has finished

View File

@@ -74,19 +74,19 @@ void WeightedThreadPool::init()
void WeightedThreadPool::setQueueSize(size_t queueSize)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
fQueueSize = queueSize;
}
void WeightedThreadPool::setMaxThreads(size_t maxThreads)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
fMaxThreads = maxThreads;
}
void WeightedThreadPool::setMaxThreadWeight(size_t maxWeight)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
fMaxThreadWeight = maxWeight;
}
@@ -97,7 +97,7 @@ void WeightedThreadPool::setThreadCreatedListener(const Functor_T& f)
void WeightedThreadPool::stop()
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
fStop = true;
lock1.unlock();
@@ -107,7 +107,7 @@ void WeightedThreadPool::stop()
void WeightedThreadPool::wait()
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
while (fWaitingFunctorsSize > 0)
{
@@ -119,7 +119,7 @@ void WeightedThreadPool::wait()
void WeightedThreadPool::removeJobs(uint32_t id)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
Container_T::iterator it;
it = fNextFunctor;
@@ -146,7 +146,7 @@ void WeightedThreadPool::removeJobs(uint32_t id)
void WeightedThreadPool::invoke(const Functor_T& threadfunc, uint32_t functor_weight, uint32_t id)
{
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
for (;;)
{
@@ -216,7 +216,7 @@ void WeightedThreadPool::beginThread() throw()
try
{
// fThreadCreated();
std::unique_lock lock1(fMutex);
boost::mutex::scoped_lock lock1(fMutex);
for (;;)
{

View File

@@ -30,9 +30,8 @@
#include <sstream>
#include <stdexcept>
#include <boost/thread/thread.hpp>
#include <map>
#include <mutex>
#include <condition_variable>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
@@ -222,9 +221,9 @@ class WeightedThreadPool
Container_T::iterator fNextFunctor;
uint32_t issued;
std::mutex fMutex;
std::condition_variable fThreadAvailable; // triggered when a thread is available
std::condition_variable fNeedThread; // triggered when a thread is needed
boost::mutex fMutex;
boost::condition fThreadAvailable; // triggered when a thread is available
boost::condition fNeedThread; // triggered when a thread is needed
boost::thread_group fThreads;
bool fStop;

View File

@@ -31,7 +31,7 @@ using namespace std;
#include "weightedthreadpool.h"
int thecount = 0;
std::mutex mutex;
boost::mutex mutex;
// Functor class
struct foo
@@ -42,7 +42,7 @@ struct foo
// simulate some work
fData++;
// std::unique_lock lock(mutex);
// boost::mutex::scoped_lock lock(mutex);
// std::cout << "foo count = " << ++thecount << " " << fData << std::endl;
}
@@ -70,7 +70,7 @@ int main(int argc, char** argv)
pool.invoke(bar, 25);
}
std::unique_lock lock(mutex);
boost::mutex::scoped_lock lock(mutex);
std::cout << "count = " << ++thecount << std::endl;
// Wait until all of the queued up and in-progress work has finished