You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
clang format apply
This commit is contained in:
@ -16,9 +16,9 @@
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
/*******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************/
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* we_cpifeederthread.cpp
|
||||
@ -27,7 +27,6 @@
|
||||
* Author: bpaul
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
@ -48,148 +47,138 @@ using namespace messageqcpp;
|
||||
|
||||
namespace WriteEngine
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void WECpiFeederRunner::operator()()
|
||||
{
|
||||
fOwner.feedData2Cpi();
|
||||
cout << "Finished running Feeder Thread!!" << endl;
|
||||
fOwner.feedData2Cpi();
|
||||
cout << "Finished running Feeder Thread!!" << endl;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
WECpiFeederThread::WECpiFeederThread(WEDataLoader& Ref):
|
||||
fOwner(Ref),
|
||||
fpThread(0),
|
||||
fContinue(true),
|
||||
fStopped(true)
|
||||
WECpiFeederThread::WECpiFeederThread(WEDataLoader& Ref)
|
||||
: fOwner(Ref), fpThread(0), fContinue(true), fStopped(true)
|
||||
{
|
||||
cout << "Inside WECpiFeederThread constructor" << endl;
|
||||
cout << "Inside WECpiFeederThread constructor" << endl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
WECpiFeederThread::~WECpiFeederThread()
|
||||
{
|
||||
if (fpThread)
|
||||
{
|
||||
delete fpThread;
|
||||
}
|
||||
if (fpThread)
|
||||
{
|
||||
delete fpThread;
|
||||
}
|
||||
|
||||
fpThread = 0;
|
||||
fpThread = 0;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void WECpiFeederThread::startFeederThread()
|
||||
{
|
||||
fStopped = false;
|
||||
cout << "Starting Feeder Thread!!" << endl;
|
||||
fpThread = new boost::thread(WECpiFeederRunner(*this));
|
||||
fStopped = false;
|
||||
cout << "Starting Feeder Thread!!" << endl;
|
||||
fpThread = new boost::thread(WECpiFeederRunner(*this));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void WECpiFeederThread::add2MsgQueue(ByteStream& Ibs)
|
||||
{
|
||||
|
||||
//TODO creating copy is NOT good; later read from socket using a SBS
|
||||
messageqcpp::SBS aSbs(new messageqcpp::ByteStream(Ibs));
|
||||
Ibs.reset(); //forcefully clearing it
|
||||
boost::mutex::scoped_lock aLock(fMsgQMutex);
|
||||
//cout << "pushing to the MsgQueue" << endl;
|
||||
fMsgQueue.push(aSbs);
|
||||
fFeederCond.notify_one(); // as per preference of Damon
|
||||
aLock.unlock();
|
||||
|
||||
// TODO creating copy is NOT good; later read from socket using a SBS
|
||||
messageqcpp::SBS aSbs(new messageqcpp::ByteStream(Ibs));
|
||||
Ibs.reset(); // forcefully clearing it
|
||||
boost::mutex::scoped_lock aLock(fMsgQMutex);
|
||||
// cout << "pushing to the MsgQueue" << endl;
|
||||
fMsgQueue.push(aSbs);
|
||||
fFeederCond.notify_one(); // as per preference of Damon
|
||||
aLock.unlock();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void WECpiFeederThread::feedData2Cpi()
|
||||
{
|
||||
while (isContinue())
|
||||
while (isContinue())
|
||||
{
|
||||
boost::mutex::scoped_lock aLock(fMsgQMutex);
|
||||
|
||||
if (fMsgQueue.empty())
|
||||
{
|
||||
bool aTimedOut = fFeederCond.timed_wait(aLock, boost::posix_time::milliseconds(3000));
|
||||
|
||||
boost::mutex::scoped_lock aLock(fMsgQMutex);
|
||||
|
||||
if (fMsgQueue.empty())
|
||||
{
|
||||
bool aTimedOut = fFeederCond.timed_wait(aLock, boost::posix_time::milliseconds(3000));
|
||||
|
||||
if (!isContinue())
|
||||
{
|
||||
aLock.unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
// to handle spurious wake ups and timeout wake ups
|
||||
if ((fMsgQueue.empty()) || (!aTimedOut))
|
||||
{
|
||||
aLock.unlock();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
messageqcpp::SBS aSbs = fMsgQueue.front();
|
||||
fMsgQueue.pop();
|
||||
|
||||
if (!isContinue())
|
||||
{
|
||||
aLock.unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
fOwner.pushData2Cpimport((*aSbs));
|
||||
//cout << "Finished PUSHING data " << endl;
|
||||
}
|
||||
catch (runtime_error&)
|
||||
{
|
||||
//cout << "Caught exception : " << e.what() << endl;
|
||||
//break;
|
||||
}
|
||||
|
||||
aSbs.reset(); //forcefully clearing it
|
||||
|
||||
// We start sending data request from here ONLY
|
||||
if (getQueueSize() == WEDataLoader::MAX_QSIZE) fOwner.sendDataRequest();
|
||||
// to handle spurious wake ups and timeout wake ups
|
||||
if ((fMsgQueue.empty()) || (!aTimedOut))
|
||||
{
|
||||
aLock.unlock();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "CpiFeedThread Stopped!! " << endl;
|
||||
fStopped = true;
|
||||
messageqcpp::SBS aSbs = fMsgQueue.front();
|
||||
fMsgQueue.pop();
|
||||
|
||||
aLock.unlock();
|
||||
|
||||
try
|
||||
{
|
||||
fOwner.pushData2Cpimport((*aSbs));
|
||||
// cout << "Finished PUSHING data " << endl;
|
||||
}
|
||||
catch (runtime_error&)
|
||||
{
|
||||
// cout << "Caught exception : " << e.what() << endl;
|
||||
// break;
|
||||
}
|
||||
|
||||
aSbs.reset(); // forcefully clearing it
|
||||
|
||||
// We start sending data request from here ONLY
|
||||
if (getQueueSize() == WEDataLoader::MAX_QSIZE)
|
||||
fOwner.sendDataRequest();
|
||||
}
|
||||
|
||||
cout << "CpiFeedThread Stopped!! " << endl;
|
||||
fStopped = true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool WECpiFeederThread::isMsgQueueEmpty()
|
||||
{
|
||||
bool aRet = false;
|
||||
boost::mutex::scoped_lock aLock(fMsgQMutex);
|
||||
aRet = fMsgQueue.empty();
|
||||
aLock.unlock();
|
||||
return aRet;
|
||||
bool aRet = false;
|
||||
boost::mutex::scoped_lock aLock(fMsgQMutex);
|
||||
aRet = fMsgQueue.empty();
|
||||
aLock.unlock();
|
||||
return aRet;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void WECpiFeederThread::stopThread()
|
||||
{
|
||||
boost::mutex::scoped_lock aCondLock(fContMutex);
|
||||
fContinue = false;
|
||||
aCondLock.unlock();
|
||||
fFeederCond.notify_all();
|
||||
cout << "Notified all" << endl;
|
||||
boost::mutex::scoped_lock aCondLock(fContMutex);
|
||||
fContinue = false;
|
||||
aCondLock.unlock();
|
||||
fFeederCond.notify_all();
|
||||
cout << "Notified all" << endl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
bool WECpiFeederThread::isContinue()
|
||||
{
|
||||
boost::mutex::scoped_lock aCondLock(fContMutex);
|
||||
return fContinue;
|
||||
boost::mutex::scoped_lock aCondLock(fContMutex);
|
||||
return fContinue;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
} /* namespace WriteEngine */
|
||||
|
Reference in New Issue
Block a user