|
Mixe for Privacy and Anonymity in the Internet
|
A thread that settles CCs with the BI. More...
#include <CAAccountingSettleThread.hpp>
Public Member Functions | |
| CAAccountingSettleThread (Hashtable *a_accountingHashtable, UINT8 *currentCascade) | |
| ~CAAccountingSettleThread () | |
| void | settle () |
Static Private Member Functions | |
| static THREAD_RETURN | mainLoop (void *param) |
| The main loop. | |
Private Attributes | |
| CAConditionVariable * | m_pCondition |
| CAConditionVariable * | m_pForcedSettlementCondition |
| UINT8 * | m_settleCascade |
| CAThread * | m_pThread |
| volatile bool | m_bRun |
| Hashtable * | m_accountingHashtable |
| bool | m_bSleep |
A thread that settles CCs with the BI.
Definition at line 62 of file CAAccountingSettleThread.hpp.
| CAAccountingSettleThread::CAAccountingSettleThread | ( | Hashtable * | a_accountingHashtable, |
| UINT8 * | currentCascade | ||
| ) |
Definition at line 41 of file CAAccountingSettleThread.cpp.
References m_accountingHashtable, m_bRun, m_pCondition, m_pThread, m_settleCascade, mainLoop(), CAMsg::printMsg(), CAThread::setMainLoop(), and CAThread::start().
{
// launch AI thread
m_pThread = new CAThread((UINT8*)"Accounting Settle Thread");
m_settleCascade = currentCascade;
//m_pPiInterface = pPiInterface;
//m_pDbInterface = pDbInterface;
m_pThread->setMainLoop( mainLoop );
CAMsg::printMsg(LOG_DEBUG, "Now launching Accounting SettleThread...\n");
m_bRun=true;
m_accountingHashtable = a_accountingHashtable;
m_pCondition = new CAConditionVariable;
m_pThread->start(this);
}
Definition at line 60 of file CAAccountingSettleThread.cpp.
References CAThread::join(), m_bRun, m_pCondition, m_pThread, and settle().
{
m_bRun=false;
if(m_pThread != NULL)
{
settle();
m_pThread->join();
delete m_pThread;
m_pThread = NULL;
}
if(m_pCondition != NULL)
{
delete m_pCondition;
m_pCondition = NULL;
}
}
| THREAD_RETURN CAAccountingSettleThread::mainLoop | ( | void * | pParam | ) | [static, private] |
The main loop.
Sleeps for a few minutes, then contacts the BI to settle CCs, then sleeps again
Definition at line 90 of file CAAccountingSettleThread.cpp.
References BEGIN_STACK, E_SUCCESS, FINISH_STACK, CALibProxytest::getOptions(), CACmdLnOptions::getPaymentSettleInterval(), INIT_STACK, CAMutex::lock(), m_bRun, m_pCondition, CAAccountingInstance::newSettlementTransaction(), CAMsg::printMsg(), THREAD_RETURN_SUCCESS, CAMutex::unlock(), and CAConditionVariable::wait().
Referenced by CAAccountingSettleThread().
{
INIT_STACK;
BEGIN_STACK("CAAccountingSettleThread::mainLoop");
UINT32 settlement_status;
UINT32 sleepInterval = CALibProxytest::getOptions()->getPaymentSettleInterval();
CAAccountingSettleThread* m_pAccountingSettleThread=(CAAccountingSettleThread*)pParam;
CAMsg::printMsg(LOG_DEBUG, "AccountingSettleThread: Start loop...\n");
while(m_pAccountingSettleThread->m_bRun) {
m_pAccountingSettleThread->m_pCondition->lock();
m_pAccountingSettleThread->m_pCondition->wait(sleepInterval * 1000);
m_pAccountingSettleThread->m_pCondition->unlock();
settlement_status = CAAccountingInstance::newSettlementTransaction();
if(settlement_status != E_SUCCESS)
{
CAMsg::printMsg(LOG_ERR, "AccountingSettleThread: Settlement transaction failed\n");
}
}
FINISH_STACK("CAAccountingSettleThread::mainLoop");
CAMsg::printMsg(LOG_DEBUG, "AccountingSettleThread: Exiting run loop!\n");
/*dbConn.terminateDBConnection();
delete biConn;
biConn = NULL;*/
THREAD_RETURN_SUCCESS;
}
| void CAAccountingSettleThread::settle | ( | ) |
Definition at line 78 of file CAAccountingSettleThread.cpp.
References CAMutex::lock(), m_pCondition, CAConditionVariable::signal(), and CAMutex::unlock().
Referenced by CAAccountingInstance::handleCostConfirmation_internal(), and ~CAAccountingSettleThread().
{
m_pCondition->lock();
//m_bSleep = false;
m_pCondition->signal();
m_pCondition->unlock();
}
Definition at line 78 of file CAAccountingSettleThread.hpp.
Referenced by CAAccountingSettleThread().
volatile bool CAAccountingSettleThread::m_bRun [private] |
Definition at line 77 of file CAAccountingSettleThread.hpp.
Referenced by CAAccountingSettleThread(), mainLoop(), and ~CAAccountingSettleThread().
bool CAAccountingSettleThread::m_bSleep [private] |
Definition at line 79 of file CAAccountingSettleThread.hpp.
Definition at line 72 of file CAAccountingSettleThread.hpp.
Referenced by CAAccountingSettleThread(), mainLoop(), settle(), and ~CAAccountingSettleThread().
Definition at line 73 of file CAAccountingSettleThread.hpp.
CAThread* CAAccountingSettleThread::m_pThread [private] |
Definition at line 76 of file CAAccountingSettleThread.hpp.
Referenced by CAAccountingSettleThread(), and ~CAAccountingSettleThread().
UINT8* CAAccountingSettleThread::m_settleCascade [private] |
Definition at line 74 of file CAAccountingSettleThread.hpp.
Referenced by CAAccountingSettleThread().
1.7.6.1