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

MCOL-513 fix a couple bugs in threadpool join() Add a test program

This commit is contained in:
David Hall
2017-02-01 17:22:15 -06:00
parent c4742b8363
commit b6321935fb
5 changed files with 412 additions and 4 deletions

View File

@ -20,7 +20,7 @@
*
*
***********************************************************************/
#define NOLOGGING
#include <stdexcept>
using namespace std;
@ -127,6 +127,7 @@ void ThreadPool::join(uint64_t thrHandle)
bool foundit = false;
for (iter = fWaitingFunctors.begin(); iter != end; ++iter)
{
foundit = false;
if (iter->first == thrHandle)
{
foundit = true;
@ -141,6 +142,42 @@ void ThreadPool::join(uint64_t thrHandle)
}
}
void ThreadPool::join(std::vector<uint64_t> thrHandle)
{
boost::mutex::scoped_lock lock1(fMutex);
while (waitingFunctorsSize > 0)
{
Container_T::iterator iter;
Container_T::iterator end = fWaitingFunctors.end();
bool foundit = false;
for (iter = fWaitingFunctors.begin(); iter != end; ++iter)
{
foundit = false;
std::vector<uint64_t>::iterator thrIter;
std::vector<uint64_t>::iterator thrEnd = thrHandle.end();
for (thrIter = thrHandle.begin(); thrIter != thrEnd; ++thrIter)
{
if (iter->first == *thrIter)
{
foundit = true;
break;
}
}
if (foundit == true)
{
break;
}
}
// If we didn't find any of the handles, then all are complete
if (!foundit)
{
break;
}
fThreadAvailable.wait(lock1);
}
}
int64_t ThreadPool::invoke(const Functor_T &threadfunc)
{
boost::mutex::scoped_lock lock1(fMutex);
@ -276,6 +313,7 @@ void ThreadPool::beginThread() throw()
// Log the exception and exit this thread
try
{
#ifndef NOLOGGING
logging::Message::Args args;
logging::Message message(5);
args.add("beginThread: Caught exception: ");
@ -287,7 +325,7 @@ void ThreadPool::beginThread() throw()
logging::MessageLog ml(lid);
ml.logErrorMessage( message );
#endif
}
catch(...)
{
@ -302,6 +340,7 @@ void ThreadPool::beginThread() throw()
// Log the exception and exit this thread
try
{
#ifndef NOLOGGING
logging::Message::Args args;
logging::Message message(6);
args.add("beginThread: Caught unknown exception!");
@ -312,7 +351,7 @@ void ThreadPool::beginThread() throw()
logging::MessageLog ml(lid);
ml.logErrorMessage( message );
#endif
}
catch(...)
{