Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
CAAccountingSettleThread Class Reference

A thread that settles CCs with the BI. More...

#include <CAAccountingSettleThread.hpp>

Collaboration diagram for CAAccountingSettleThread:

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. More...
 

Private Attributes

CAConditionVariablem_pCondition
 
CAConditionVariablem_pForcedSettlementCondition
 
UINT8m_settleCascade
 
CAThreadm_pThread
 
volatile bool m_bRun
 
Hashtable * m_accountingHashtable
 
bool m_bSleep
 

Detailed Description

A thread that settles CCs with the BI.

Author
Bastian Voigt
Todo:
make SLEEP_SECONDS a configure option

Definition at line 62 of file CAAccountingSettleThread.hpp.

Constructor & Destructor Documentation

◆ CAAccountingSettleThread()

CAAccountingSettleThread::CAAccountingSettleThread ( Hashtable *  a_accountingHashtable,
UINT8 currentCascade 
)

Definition at line 41 of file CAAccountingSettleThread.cpp.

45 {
46  // launch AI thread
47  m_pThread = new CAThread((UINT8*)"Accounting Settle Thread");
48  m_settleCascade = currentCascade;
49  //m_pPiInterface = pPiInterface;
50  //m_pDbInterface = pDbInterface;
52  CAMsg::printMsg(LOG_DEBUG, "Now launching Accounting SettleThread...\n");
53  m_bRun=true;
54  m_accountingHashtable = a_accountingHashtable;
56  m_pThread->start(this);
57 }
unsigned char UINT8
Definition: basetypedefs.h:135
CAConditionVariable * m_pCondition
static THREAD_RETURN mainLoop(void *param)
The main loop.
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
SINT32 start(void *param, bool bDaemon=false, bool bSilent=false)
Starts the execution of the main function of this thread.
Definition: CAThread.cpp:115
SINT32 setMainLoop(THREAD_MAIN_TYP fnc)
Sets the main function which will be executed within this thread.
Definition: CAThread.hpp:148

References m_accountingHashtable, m_bRun, m_pCondition, m_pThread, m_settleCascade, mainLoop(), CAMsg::printMsg(), CAThread::setMainLoop(), and CAThread::start().

Here is the call graph for this function:

◆ ~CAAccountingSettleThread()

CAAccountingSettleThread::~CAAccountingSettleThread ( )

Definition at line 60 of file CAAccountingSettleThread.cpp.

61  {
62  m_bRun=false;
63  if(m_pThread != NULL)
64  {
65  settle();
66  m_pThread->join();
67  delete m_pThread;
68  m_pThread = NULL;
69  }
70  if(m_pCondition != NULL)
71  {
72  delete m_pCondition;
73  m_pCondition = NULL;
74  }
75  }
SINT32 join()
Waits for the main function to finish execution.
Definition: CAThread.cpp:187

References CAThread::join(), m_bRun, m_pCondition, m_pThread, and settle().

Here is the call graph for this function:

Member Function Documentation

◆ mainLoop()

THREAD_RETURN CAAccountingSettleThread::mainLoop ( void *  pParam)
staticprivate

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.

91  {
92  INIT_STACK;
93  BEGIN_STACK("CAAccountingSettleThread::mainLoop");
94 
95  UINT32 settlement_status;
97 
98  CAAccountingSettleThread* m_pAccountingSettleThread=(CAAccountingSettleThread*)pParam;
99 
100  CAMsg::printMsg(LOG_DEBUG, "AccountingSettleThread: Start loop...\n");
101 
102  while(m_pAccountingSettleThread->m_bRun) {
103  m_pAccountingSettleThread->m_pCondition->lock();
104  m_pAccountingSettleThread->m_pCondition->wait(sleepInterval * 1000);
105  m_pAccountingSettleThread->m_pCondition->unlock();
107  if(settlement_status != E_SUCCESS)
108  {
109  CAMsg::printMsg(LOG_ERR, "AccountingSettleThread: Settlement transaction failed\n");
110  }
111  }
112 
113  FINISH_STACK("CAAccountingSettleThread::mainLoop");
114 
115  CAMsg::printMsg(LOG_DEBUG, "AccountingSettleThread: Exiting run loop!\n");
116  /*dbConn.terminateDBConnection();
117  delete biConn;
118  biConn = NULL;*/
120  }
#define INIT_STACK
Definition: CAThread.hpp:48
#define BEGIN_STACK(methodName)
Definition: CAThread.hpp:49
#define FINISH_STACK(methodName)
Definition: CAThread.hpp:50
#define THREAD_RETURN_SUCCESS
Definition: StdAfx.h:542
unsigned int UINT32
Definition: basetypedefs.h:131
static SINT32 newSettlementTransaction()
A thread that settles CCs with the BI.
UINT32 getPaymentSettleInterval()
SINT32 wait()
Waits for a signal or for a timeout.
static CACmdLnOptions * getOptions()
SINT32 unlock()
Definition: CAMutex.hpp:52
SINT32 lock()
Definition: CAMutex.hpp:41
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ settle()

void CAAccountingSettleThread::settle ( )

Definition at line 78 of file CAAccountingSettleThread.cpp.

79 {
80  m_pCondition->lock();
81  //m_bSleep = false;
84 }
SINT32 signal()
Signals this object.

References CAMutex::lock(), m_pCondition, CAConditionVariable::signal(), and CAMutex::unlock().

Referenced by CAAccountingInstance::handleCostConfirmation_internal(), and ~CAAccountingSettleThread().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_accountingHashtable

Hashtable* CAAccountingSettleThread::m_accountingHashtable
private

Definition at line 78 of file CAAccountingSettleThread.hpp.

Referenced by CAAccountingSettleThread().

◆ m_bRun

volatile bool CAAccountingSettleThread::m_bRun
private

◆ m_bSleep

bool CAAccountingSettleThread::m_bSleep
private

Definition at line 79 of file CAAccountingSettleThread.hpp.

◆ m_pCondition

CAConditionVariable* CAAccountingSettleThread::m_pCondition
private

◆ m_pForcedSettlementCondition

CAConditionVariable* CAAccountingSettleThread::m_pForcedSettlementCondition
private

Definition at line 73 of file CAAccountingSettleThread.hpp.

◆ m_pThread

CAThread* CAAccountingSettleThread::m_pThread
private

◆ m_settleCascade

UINT8* CAAccountingSettleThread::m_settleCascade
private

Definition at line 74 of file CAAccountingSettleThread.hpp.

Referenced by CAAccountingSettleThread().


The documentation for this class was generated from the following files: