You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-4486 Removing deadlock implicitly introduced by the deprecated class boost::condition
This commit is contained in:
@ -87,14 +87,15 @@ void ThreadPool::setQueueSize(size_t queueSize)
|
|||||||
|
|
||||||
void ThreadPool::pruneThread()
|
void ThreadPool::pruneThread()
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock2(fPruneMutex);
|
boost::unique_lock<boost::mutex> lock2(fPruneMutex);
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
boost::system_time timeout = boost::get_system_time() + boost::posix_time::minutes(1);
|
|
||||||
if (fStop)
|
if (fStop)
|
||||||
return;
|
return;
|
||||||
if (!fPruneThreadEnd.timed_wait(fPruneMutex, timeout))
|
if (fPruneThreadEnd.wait_for(lock2, boost::chrono::minutes{1}) ==
|
||||||
|
boost::cv_status::timeout)
|
||||||
{
|
{
|
||||||
while(!fPruneThreads.empty())
|
while(!fPruneThreads.empty())
|
||||||
{
|
{
|
||||||
@ -327,8 +328,7 @@ void ThreadPool::beginThread() throw()
|
|||||||
utils::setThreadName("Idle");
|
utils::setThreadName("Idle");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock1(fMutex);
|
boost::unique_lock<boost::mutex> lock1(fMutex);
|
||||||
boost::system_time timeout = boost::get_system_time() + boost::posix_time::minutes(10);
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -347,7 +347,8 @@ void ThreadPool::beginThread() throw()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Wait no more than 10 minutes
|
// Wait no more than 10 minutes
|
||||||
if (!fNeedThread.timed_wait(lock1, timeout)) // false means it timed out
|
if (fNeedThread.wait_for(lock1, boost::chrono::minutes{10}) ==
|
||||||
|
boost::cv_status::timeout)
|
||||||
{
|
{
|
||||||
if (fThreadCount > fMaxThreads)
|
if (fThreadCount > fMaxThreads)
|
||||||
{
|
{
|
||||||
@ -356,8 +357,6 @@ void ThreadPool::beginThread() throw()
|
|||||||
--fThreadCount;
|
--fThreadCount;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout = boost::get_system_time() + boost::posix_time::minutes(10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,7 +389,7 @@ void ThreadPool::beginThread() throw()
|
|||||||
|
|
||||||
lock1.unlock();
|
lock1.unlock();
|
||||||
|
|
||||||
utils::setThreadName("Unspecified");
|
utils::setThreadName("Unspecified");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
todo->functor();
|
todo->functor();
|
||||||
@ -434,8 +433,6 @@ void ThreadPool::beginThread() throw()
|
|||||||
ml.logWarningMessage( message );
|
ml.logWarningMessage( message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout = boost::get_system_time() + boost::posix_time::minutes(10);
|
|
||||||
fThreadAvailable.notify_all();
|
fThreadAvailable.notify_all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,12 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <boost/thread/thread.hpp>
|
#include <boost/thread/thread.hpp>
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/condition.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
|
#include <boost/thread/locks.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
#include <boost/chrono/chrono.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -54,7 +56,6 @@
|
|||||||
|
|
||||||
namespace threadpool
|
namespace threadpool
|
||||||
{
|
{
|
||||||
|
|
||||||
// Taken from boost::thread_group and adapted
|
// Taken from boost::thread_group and adapted
|
||||||
class ThreadPoolGroup
|
class ThreadPoolGroup
|
||||||
{
|
{
|
||||||
@ -351,8 +352,8 @@ private:
|
|||||||
|
|
||||||
uint32_t fIssued;
|
uint32_t fIssued;
|
||||||
boost::mutex fMutex;
|
boost::mutex fMutex;
|
||||||
boost::condition fThreadAvailable; // triggered when a thread is available
|
boost::condition_variable fThreadAvailable; // triggered when a thread is available
|
||||||
boost::condition fNeedThread; // triggered when a thread is needed
|
boost::condition_variable fNeedThread; // triggered when a thread is needed
|
||||||
ThreadPoolGroup fThreads;
|
ThreadPoolGroup fThreads;
|
||||||
|
|
||||||
bool fStop;
|
bool fStop;
|
||||||
@ -365,7 +366,7 @@ private:
|
|||||||
bool fDebug;
|
bool fDebug;
|
||||||
boost::mutex fInitMutex;
|
boost::mutex fInitMutex;
|
||||||
boost::mutex fPruneMutex;
|
boost::mutex fPruneMutex;
|
||||||
boost::condition fPruneThreadEnd;
|
boost::condition_variable fPruneThreadEnd;
|
||||||
boost::thread* fPruneThread;
|
boost::thread* fPruneThread;
|
||||||
std::stack<boost::thread::id> fPruneThreads; // A list of stale thread IDs to be joined
|
std::stack<boost::thread::id> fPruneThreads; // A list of stale thread IDs to be joined
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user