You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-13 23:02:14 +03:00
Fixed a really dumb bug in threadpool that would leave no threads
left to process jobs. Also added an accessor to see how big the job queue is.
This commit is contained in:
@@ -13,6 +13,7 @@ ThreadPool::ThreadPool() : maxThreads(1000), die(false), threadsWaiting(0)
|
||||
// context it's used in. In the CRP class for example, the # of active threads would be
|
||||
// naturally limited by the # of concurrent operations.
|
||||
logger = SMLogging::get();
|
||||
pruner = boost::thread([this] { this->prune(); } );
|
||||
}
|
||||
|
||||
ThreadPool::ThreadPool(uint num_threads, bool _processQueueOnExit) : maxThreads(num_threads), die(false),
|
||||
@@ -62,8 +63,9 @@ void ThreadPool::prune()
|
||||
{
|
||||
while (pruneable.empty() && !die)
|
||||
somethingToPrune.wait(s);
|
||||
|
||||
if (die)
|
||||
return;
|
||||
break;
|
||||
|
||||
for (auto &id : pruneable)
|
||||
{
|
||||
@@ -83,6 +85,12 @@ void ThreadPool::setMaxThreads(uint newMax)
|
||||
maxThreads = newMax;
|
||||
}
|
||||
|
||||
int ThreadPool::currentQueueSize() const
|
||||
{
|
||||
boost::unique_lock<boost::mutex> s(mutex);
|
||||
return jobs.size();
|
||||
}
|
||||
|
||||
void ThreadPool::processingLoop()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -27,6 +27,7 @@ class ThreadPool : public boost::noncopyable
|
||||
|
||||
void addJob(const boost::shared_ptr<Job> &j);
|
||||
void setMaxThreads(uint newMax);
|
||||
int currentQueueSize() const;
|
||||
|
||||
private:
|
||||
void processingLoop(); // the fcn run by each thread
|
||||
@@ -57,7 +58,7 @@ class ThreadPool : public boost::noncopyable
|
||||
|
||||
boost::condition jobAvailable;
|
||||
std::deque<boost::shared_ptr<Job> > jobs;
|
||||
boost::mutex mutex;
|
||||
mutable boost::mutex mutex;
|
||||
|
||||
const boost::posix_time::time_duration idleThreadTimeout = boost::posix_time::seconds(60);
|
||||
boost::thread pruner;
|
||||
|
||||
Reference in New Issue
Block a user