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

#include <CAReplayDatabase.hpp>

Collaboration diagram for CAReplayDatabase:

Public Member Functions

 CAReplayDatabase ()
 
 ~CAReplayDatabase ()
 
SINT32 insert (UINT8 key[16])
 Inserts this key in the replay DB. More...
 
SINT32 start ()
 
SINT32 stop ()
 
SINT32 getCurrentReplayTimestamp (tReplayTimestamp &replayTimestamp) const
 Returns the current Replay timestamp for this database. More...
 
UINT32 getRefTime () const
 Returns the local time in seconds since epoch for replay timestamp='0' for this database. More...
 

Static Public Member Functions

static SINT32 getReplayTimestampForTime (tReplayTimestamp &replayTimestamp, UINT32 aktTime, UINT32 refTime)
 Returns the replay timestamp for this reference time (seconds since epoch) and time. More...
 
static SINT32 getTimeForReplayTimestamp (UINT32 &refTime, tReplayTimestamp replayTimestamp)
 Returns the refernce time (seconds since epoch) for the given replay timestamp. More...
 
static SINT32 test ()
 
static SINT32 measurePerformance (UINT8 *strLogFile, UINT32 lowerBoundEntries, UINT32 upperBoundEntries, UINT32 stepBy, UINT32 meassuresPerStep, UINT32 insertsPerMeasure)
 This mehtod can be used to measure the performance of the Replay database. More...
 

Private Member Functions

LP_replay_databaseEntry getNewDBEntry (t_replay_databaseInfo *pDB)
 
t_replay_databaseInfocreateDBInfo ()
 Creates and initialises a dbinfo struct. More...
 
SINT32 clearDB (t_replay_databaseInfo *pDB)
 clears the whole database pDB - but does not delete the hashtable pDB More...
 
SINT32 deleteDB (t_replay_databaseInfo *&pDB)
 Deletes the whole database pDB. More...
 
SINT32 nextClock ()
 
SINT32 fill (UINT32 nrOfEntries)
 Pre fills the database with nrOfEntries random entries. More...
 
SINT32 simulateInsert (UINT8 key[16])
 This is a modified copy of insert() which simulates the insert() function as close as possible without actually changing the replay database. More...
 

Private Attributes

t_replay_databaseInfom_currDatabase
 
t_replay_databaseInfom_nextDatabase
 
t_replay_databaseInfom_prevDatabase
 
volatile bool m_bRun
 
UINT32 m_refTime
 
volatile SINT32 m_currentClock
 
CAMutexm_pMutex
 
CAThreadm_pThread
 

Friends

THREAD_RETURN replaydb_loopMaintenance (void *param)
 

Detailed Description

Definition at line 64 of file CAReplayDatabase.hpp.

Constructor & Destructor Documentation

◆ CAReplayDatabase()

CAReplayDatabase::CAReplayDatabase ( )

Definition at line 34 of file CAReplayDatabase.cpp.

35  {
39  m_refTime=time(NULL);
41  m_pThread=NULL;
42  m_pMutex=new CAMutex();
43  }
t_replay_databaseInfo * m_currDatabase
t_replay_databaseInfo * m_prevDatabase
t_replay_databaseInfo * createDBInfo()
Creates and initialises a dbinfo struct.
t_replay_databaseInfo * m_nextDatabase
volatile SINT32 m_currentClock

References createDBInfo(), m_currDatabase, m_currentClock, m_nextDatabase, m_pMutex, m_prevDatabase, m_pThread, and m_refTime.

Referenced by measurePerformance().

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

◆ ~CAReplayDatabase()

CAReplayDatabase::~CAReplayDatabase ( )

Definition at line 52 of file CAReplayDatabase.cpp.

53  {
54  m_pMutex->lock();
55  stop();
59  m_pMutex->unlock();
60  delete m_pMutex;
61  }
SINT32 unlock()
Definition: CAMutex.hpp:52
SINT32 lock()
Definition: CAMutex.hpp:41
SINT32 deleteDB(t_replay_databaseInfo *&pDB)
Deletes the whole database pDB.

References deleteDB(), CAMutex::lock(), m_currDatabase, m_nextDatabase, m_pMutex, m_prevDatabase, stop(), and CAMutex::unlock().

Here is the call graph for this function:

Member Function Documentation

◆ clearDB()

SINT32 CAReplayDatabase::clearDB ( t_replay_databaseInfo pDB)
private

clears the whole database pDB - but does not delete the hashtable pDB

Parameters
pDBdatabase to delete

Definition at line 63 of file CAReplayDatabase.cpp.

64  {
65  while(pDBInfo->m_pHeap!=NULL)
66  {
67  pDBInfo->m_pLastHeap=pDBInfo->m_pHeap;
68  pDBInfo->m_pHeap=pDBInfo->m_pHeap->next;
69  delete pDBInfo->m_pLastHeap;
70  }
71  memset(pDBInfo,0,sizeof(t_replay_databaseInfo));
72  return E_SUCCESS;
73  }
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2

References E_SUCCESS, __t_database_info::m_pHeap, __t_database_info::m_pLastHeap, and __t_replay_database_heap::next.

Referenced by deleteDB(), and nextClock().

Here is the caller graph for this function:

◆ createDBInfo()

t_replay_databaseInfo * CAReplayDatabase::createDBInfo ( )
private

Creates and initialises a dbinfo struct.

Definition at line 45 of file CAReplayDatabase.cpp.

46  {
48  memset(pInfo,0,sizeof(t_replay_databaseInfo));
49  return pInfo;
50  }
struct __t_database_info t_replay_databaseInfo

Referenced by CAReplayDatabase().

Here is the caller graph for this function:

◆ deleteDB()

SINT32 CAReplayDatabase::deleteDB ( t_replay_databaseInfo *&  pDB)
private

Deletes the whole database pDB.

Parameters
pDBdatabase to delete

Definition at line 75 of file CAReplayDatabase.cpp.

76  {
77  clearDB(pDBInfo);
78  delete pDBInfo;
79  pDBInfo=NULL;
80  return E_SUCCESS;
81  }
SINT32 clearDB(t_replay_databaseInfo *pDB)
clears the whole database pDB - but does not delete the hashtable pDB

References clearDB(), and E_SUCCESS.

Referenced by ~CAReplayDatabase().

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

◆ fill()

SINT32 CAReplayDatabase::fill ( UINT32  nrOfEntries)
private

Pre fills the database with nrOfEntries random entries.

Parameters
nrOfEntriesnumber of entries to put in the database

Definition at line 321 of file CAReplayDatabase.cpp.

322  {
323  UINT32 i=0;
324  UINT8 key[16];
325  key[14]=0;
326  key[15]=0;
327  while(i<nrOfEntries)
328  {
329  getRandom(key,14);
330  if(insert(key)==E_SUCCESS)
331  i++;
332  }
333  return E_SUCCESS;
334  }
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
Definition: CAUtil.cpp:346
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
SINT32 insert(UINT8 key[16])
Inserts this key in the replay DB.

References E_SUCCESS, getRandom(), and insert().

Referenced by measurePerformance().

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

◆ getCurrentReplayTimestamp()

SINT32 CAReplayDatabase::getCurrentReplayTimestamp ( tReplayTimestamp replayTimestamp) const

Returns the current Replay timestamp for this database.

Returns the current replay timestamp for this database.

Parameters
replayTimestampstores the current replay timestamp

Definition at line 249 of file CAReplayDatabase.cpp.

250  {
251  return getReplayTimestampForTime(replayTimestamp,time(NULL),m_refTime);
252  }
static SINT32 getReplayTimestampForTime(tReplayTimestamp &replayTimestamp, UINT32 aktTime, UINT32 refTime)
Returns the replay timestamp for this reference time (seconds since epoch) and time.

References getReplayTimestampForTime(), and m_refTime.

Referenced by nextClock().

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

◆ getNewDBEntry()

LP_replay_databaseEntry CAReplayDatabase::getNewDBEntry ( t_replay_databaseInfo pDB)
inlineprivate

Definition at line 112 of file CAReplayDatabase.hpp.

113  {
114  if(pDB->m_pHeap==NULL)
115  {
117  pDB->m_pHeap->next=NULL;
118  pDB->m_pLastHeap=pDB->m_pHeap;
120  }
121  else if(pDB->m_s32FreeEntries==0)
122  {
124  pDB->m_pLastHeap=pDB->m_pLastHeap->next;
125  pDB->m_pLastHeap->next=NULL;
127  }
128  return &pDB->m_pLastHeap->m_pEntries[--pDB->m_s32FreeEntries];
129  }
struct __t_replay_database_heap t_replay_databaseHeap
#define REPLAY_DB_ENTRIES_PER_HEAP
t_replay_databaseHeap * m_pHeap
t_replay_databaseHeap * m_pLastHeap
__t_replay_database_heap * next
t_replay_databaseEntry m_pEntries[REPLAY_DB_ENTRIES_PER_HEAP]

References __t_replay_database_heap::m_pEntries, __t_database_info::m_pHeap, __t_database_info::m_pLastHeap, __t_database_info::m_s32FreeEntries, __t_replay_database_heap::next, and REPLAY_DB_ENTRIES_PER_HEAP.

Referenced by insert(), and simulateInsert().

Here is the caller graph for this function:

◆ getRefTime()

UINT32 CAReplayDatabase::getRefTime ( ) const
inline

Returns the local time in seconds since epoch for replay timestamp='0' for this database.

Definition at line 76 of file CAReplayDatabase.hpp.

77  {
78  return m_refTime;
79  }

References m_refTime.

◆ getReplayTimestampForTime()

SINT32 CAReplayDatabase::getReplayTimestampForTime ( tReplayTimestamp replayTimestamp,
UINT32  aktTime,
UINT32  refTime 
)
static

Returns the replay timestamp for this reference time (seconds since epoch) and time.

Definition at line 255 of file CAReplayDatabase.cpp.

256  {
257  UINT32 timeDiff=aktTime-refTime;
258  replayTimestamp.interval=timeDiff/SECONDS_PER_INTERVALL;
259  replayTimestamp.offset=timeDiff%SECONDS_PER_INTERVALL;
260  return E_SUCCESS;
261  }
#define SECONDS_PER_INTERVALL
Definition: CADatabase.hpp:47

References E_SUCCESS, t_replay_timestamp::interval, t_replay_timestamp::offset, and SECONDS_PER_INTERVALL.

Referenced by getCurrentReplayTimestamp().

Here is the caller graph for this function:

◆ getTimeForReplayTimestamp()

static SINT32 CAReplayDatabase::getTimeForReplayTimestamp ( UINT32 refTime,
tReplayTimestamp  replayTimestamp 
)
inlinestatic

Returns the refernce time (seconds since epoch) for the given replay timestamp.

Definition at line 85 of file CAReplayDatabase.hpp.

86  {
87  time_t now=time(NULL);
88  refTime=(UINT32)(now-replayTimestamp.interval*SECONDS_PER_INTERVALL-replayTimestamp.offset);
89  return E_SUCCESS;
90  }
#define SECONDS_PER_INTERVALL

References E_SUCCESS, t_replay_timestamp::interval, t_replay_timestamp::offset, and SECONDS_PER_INTERVALL.

◆ insert()

SINT32 CAReplayDatabase::insert ( UINT8  key[16])

Inserts this key in the replay DB.

The last two bytes are the timestamp

Definition at line 84 of file CAReplayDatabase.cpp.

85  {
86  m_pMutex->lock();
87  UINT16 timestamp=(key[14]<<8)|key[15];
88  if(timestamp<m_currentClock-1||timestamp>m_currentClock+1)
89  {
90  m_pMutex->unlock();
91  return E_UNKNOWN;
92  }
94  if(timestamp>m_currentClock)
95  {
96  aktDB=m_nextDatabase;
97  }
98  else if(timestamp<m_currentClock)
99  {
100  aktDB=m_prevDatabase;
101  }
102  UINT16 hashKey=(key[8]<<8)|key[9];
103  LP_replay_databaseEntry hashList=aktDB->m_pHashTable[hashKey];
104  if(hashList==NULL)
105  {
106  LP_replay_databaseEntry newEntry=getNewDBEntry(aktDB);
107  newEntry->left=NULL;
108  newEntry->right=NULL;
109  newEntry->key=key[0]<<24|key[1]<<16|key[2]<<8|key[3];
110  aktDB->m_pHashTable[hashKey]=newEntry;
111  aktDB->m_u32Size++;
112  m_pMutex->unlock();
113  return E_SUCCESS;
114  }
115  else
116  {
117  UINT32 ret=key[0]<<24|key[1]<<16|key[2]<<8|key[3];;
118  LP_replay_databaseEntry before=NULL;
119  do
120  {
121  //newEntry->keymemcmp(key,hashList->key,6);
122  if(ret==hashList->key)
123  {
124  m_pMutex->unlock();
125  return E_UNKNOWN;
126  }
127  before=hashList;
128  if(hashList->key<ret)
129  {
130  hashList=hashList->right;
131  }
132  else
133  {
134  hashList=hashList->left;
135  }
136  } while(hashList!=NULL);
137  LP_replay_databaseEntry newEntry=getNewDBEntry(aktDB);
138  newEntry->left=newEntry->right=NULL;
139  //memcpy(newEntry->key,key,6);
140  newEntry->key=ret;
141  if(before->key<ret)
142  {
143  before->right=newEntry;
144  }
145  else
146  before->left=newEntry;
147 
148  }
149  aktDB->m_u32Size++;
150  m_pMutex->unlock();
151  return E_SUCCESS;
152  }
unsigned short UINT16
Definition: basetypedefs.h:133
LP_replay_databaseEntry getNewDBEntry(t_replay_databaseInfo *pDB)
#define E_UNKNOWN
Definition: errorcodes.hpp:3
LP_replay_databaseEntry m_pHashTable[0x10000]
__t_replay_database_entry * right
UINT32 key
__t_replay_database_entry * left

References E_UNKNOWN, getNewDBEntry(), __t_replay_database_entry::key, __t_replay_database_entry::left, CAMutex::lock(), m_currDatabase, m_currentClock, m_nextDatabase, __t_database_info::m_pHashTable, m_pMutex, m_prevDatabase, __t_replay_database_entry::right, and CAMutex::unlock().

Referenced by fill(), and test().

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

◆ measurePerformance()

SINT32 CAReplayDatabase::measurePerformance ( UINT8 strLogFile,
UINT32  lowerBoundEntries,
UINT32  upperBoundEntries,
UINT32  stepBy,
UINT32  meassuresPerStep,
UINT32  insertsPerMeasure 
)
static

This mehtod can be used to measure the performance of the Replay database.

The results are stored in a file in csv format. Ths method will do several measures with different numbers of elements in the database. These number could be specified using owerBoundEntries,upperBoundEntries and stepBy.

Parameters
strLogFilethe log file name
lowerBoundEntriesthe number of entries in the database (at beginn)
upperBoundEntriesthe number of entries in the database (at end)
stepByhow many entries should be added for each new measurement
meassuresPerStephow many measure values should be generate per step. That means that the experiement is repeated this many times.
insertsPerMeasureone measure value will be the time: (Total Insertion Time)/insertsPerMeasure

Definition at line 264 of file CAReplayDatabase.cpp.

270  {
271  initRandom();
272  CAReplayDatabase* pDatabase=NULL;
273  UINT32 aktNrOfEntries=lowerBoundEntries;
274  UINT8* key=new UINT8[insertsPerMeasure*16];
275  UINT8* aktKey;
276  SINT32 file=open((char*)strLogFile,O_CREAT|O_WRONLY|O_LARGEFILE|O_TRUNC,S_IREAD|S_IWRITE);
277  char buff[255];
278  const char* atemplate="%u,%u,%u\n";
279  const char* header="#The format is as follows: Number of Entries in DB, Number of Inserts done, Total time for Inserts (in micro seconds)\n";
280  myfilewrite(file,header,strlen(header));
281  while(aktNrOfEntries<=upperBoundEntries)
282  {
283  CAMsg::printMsg(LOG_DEBUG,"Starting measurement with %u entries in the replay database\n",aktNrOfEntries);
284  for(UINT32 i=0;i<meassuresPerStep;i++)
285  {
286  pDatabase=new CAReplayDatabase();
287  pDatabase->m_currentClock=0;
288  pDatabase->fill(aktNrOfEntries);
289  UINT64 startTime,endTime;
290  getRandom(key,insertsPerMeasure*16);
291  aktKey=key+14;
292  for(UINT32 j=0;j<insertsPerMeasure;j++)
293  {
294  *aktKey=0;
295  aktKey++;
296  *aktKey=0;
297  aktKey+=15;
298  }
299  aktKey=key;
300  getcurrentTimeMicros(startTime);
301  for(UINT32 j=0;j<insertsPerMeasure;j++)
302  {
303  pDatabase->simulateInsert(aktKey);
304  aktKey+=16;
305  }
306  getcurrentTimeMicros(endTime);
307  sprintf(buff,atemplate,aktNrOfEntries,insertsPerMeasure,diff64(endTime,startTime));
308  myfilewrite(file,buff,strlen(buff));
309  printf("Start delete \n");
310  getcurrentTimeMicros(startTime);
311  delete pDatabase;
312  getcurrentTimeMicros(endTime);
313  printf("delete takes %u microsecs\n",diff64(endTime,startTime));
314  }
315  aktNrOfEntries+=stepBy;
316  }
317  delete[] key;
318  return E_SUCCESS;
319  }
SINT32 getcurrentTimeMicros(UINT64 &u64Time)
Gets the current Systemtime in micros seconds.
Definition: CAUtil.cpp:280
SINT32 initRandom()
Definition: CAUtil.cpp:302
UINT32 diff64(const UINT64 &bigop, const UINT64 &smallop)
Definition: CAUtil.hpp:398
#define myfilewrite
Definition: StdAfx.h:493
#define O_LARGEFILE
Definition: StdAfx.h:635
#define S_IWRITE
Definition: StdAfx.h:491
#define S_IREAD
Definition: StdAfx.h:488
signed int SINT32
Definition: basetypedefs.h:132
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
SINT32 simulateInsert(UINT8 key[16])
This is a modified copy of insert() which simulates the insert() function as close as possible withou...
SINT32 fill(UINT32 nrOfEntries)
Pre fills the database with nrOfEntries random entries.

References CAReplayDatabase(), diff64(), E_SUCCESS, fill(), getcurrentTimeMicros(), getRandom(), initRandom(), m_currentClock, myfilewrite, O_LARGEFILE, CAMsg::printMsg(), S_IREAD, S_IWRITE, and simulateInsert().

Referenced by main().

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

◆ nextClock()

SINT32 CAReplayDatabase::nextClock ( )
private

Definition at line 197 of file CAReplayDatabase.cpp.

198  {
199  m_pMutex->lock();
200  tReplayTimestamp rt;
203  CAMsg::printMsg(LOG_DEBUG,"Replay DB Size was: %u\n",m_prevDatabase->m_u32Size);
208  m_nextDatabase=tmpDB;
209  m_pMutex->unlock();
210  return E_SUCCESS;
211  }
SINT32 getCurrentReplayTimestamp(tReplayTimestamp &replayTimestamp) const
Returns the current Replay timestamp for this database.
the Replaytimestamp type
Definition: typedefs.hpp:206

References clearDB(), E_SUCCESS, getCurrentReplayTimestamp(), t_replay_timestamp::interval, CAMutex::lock(), m_currDatabase, m_currentClock, m_nextDatabase, m_pMutex, m_prevDatabase, __t_database_info::m_u32Size, CAMsg::printMsg(), and CAMutex::unlock().

Here is the call graph for this function:

◆ simulateInsert()

SINT32 CAReplayDatabase::simulateInsert ( UINT8  key[16])
private

This is a modified copy of insert() which simulates the insert() function as close as possible without actually changing the replay database.

Definition at line 336 of file CAReplayDatabase.cpp.

337  {
338  m_pMutex->lock();
339  UINT16 timestamp=(key[14]<<8)|key[15];
340  if(timestamp<m_currentClock-1||timestamp>m_currentClock+1)
341  {
342  m_pMutex->unlock();
343  return E_UNKNOWN;
344  }
346  if(timestamp>m_currentClock)
347  {
348  aktDB=m_nextDatabase;
349  }
350  else if(timestamp<m_currentClock)
351  {
352  aktDB=m_prevDatabase;
353  }
354  UINT16 hashKey=(key[8]<<8)|key[9];
355  LP_replay_databaseEntry hashList=aktDB->m_pHashTable[hashKey];
356  if(hashList==NULL)
357  {
358  LP_replay_databaseEntry newEntry=getNewDBEntry(aktDB);
359  newEntry->left=NULL;
360  newEntry->right=NULL;
361  newEntry->key=key[0]<<24|key[1]<<16|key[2]<<8|key[3];
362  m_nextDatabase->m_pHashTable[hashKey]=newEntry; //we simply use the 'next' Database to simulate insert while not inserting anythign in the current db
363  aktDB->m_u32Size++;
364  m_pMutex->unlock();
365  return E_SUCCESS;
366  }
367  else
368  {
369  UINT32 ret=key[0]<<24|key[1]<<16|key[2]<<8|key[3];
370  LP_replay_databaseEntry before=NULL;
371  do
372  {
373  //newEntry->keymemcmp(key,hashList->key,6);
374  if(ret==hashList->key)
375  {
376  m_pMutex->unlock();
377  return E_UNKNOWN;
378  }
379  before=hashList;
380  if(hashList->key<ret)
381  {
382  hashList=hashList->right;
383  }
384  else
385  {
386  hashList=hashList->left;
387  }
388  } while(hashList!=NULL);
389  LP_replay_databaseEntry newEntry=getNewDBEntry(aktDB);
390  newEntry->left=newEntry->right=NULL;
391  //memcpy(newEntry->key,key,6);
392  newEntry->key=ret;
393  if(before->key<ret)
394  {
395  newEntry->right=newEntry; //do the pointer operation without actually changing the DB
396  }
397  else
398  {
399  newEntry->left=newEntry; //do the pointer operation without actually changing the DB
400  }
401  }
402  aktDB->m_u32Size++;
403  m_pMutex->unlock();
404  return E_SUCCESS;
405  }

References E_SUCCESS, E_UNKNOWN, getNewDBEntry(), __t_replay_database_entry::key, __t_replay_database_entry::left, CAMutex::lock(), m_currDatabase, m_currentClock, m_nextDatabase, __t_database_info::m_pHashTable, m_pMutex, m_prevDatabase, __t_database_info::m_u32Size, __t_replay_database_entry::right, and CAMutex::unlock().

Referenced by measurePerformance().

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

◆ start()

SINT32 CAReplayDatabase::start ( )

Definition at line 154 of file CAReplayDatabase.cpp.

155  {
156  m_pThread=new CAThread((UINT8*)"DB Maintenance Thread");
157  m_bRun=true;
159  return m_pThread->start(this);
160  }
friend THREAD_RETURN replaydb_loopMaintenance(void *param)
volatile bool m_bRun
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_bRun, m_pThread, replaydb_loopMaintenance, CAThread::setMainLoop(), and CAThread::start().

Referenced by test().

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

◆ stop()

SINT32 CAReplayDatabase::stop ( )

Definition at line 162 of file CAReplayDatabase.cpp.

163  {
164  m_bRun=false;
165  SINT32 ret=E_SUCCESS;
166  if(m_pThread!=NULL)
167  {
168  ret=m_pThread->join();
169  delete m_pThread;
170  m_pThread=NULL;
171  }
172  return ret;
173  }
SINT32 join()
Waits for the main function to finish execution.
Definition: CAThread.cpp:187

References E_SUCCESS, CAThread::join(), m_bRun, and m_pThread.

Referenced by test(), and ~CAReplayDatabase().

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

◆ test()

SINT32 CAReplayDatabase::test ( )
static

TODO WRONG - fixme

Definition at line 213 of file CAReplayDatabase.cpp.

214  {
215  CAReplayDatabase oDatabase;
216  oDatabase.start();
217  UINT8 key[16];
218  memset(key,0,16);
219  UINT32 i;
220  for(i=0;i<20;i++)
221  {
222  getRandom(key,1);
223  oDatabase.insert(key);
224  }
225  for(i=0;i<200000;i++)
226  {
227  getRandom(key,16);
228  oDatabase.insert(key);//TODO WRONG - Fixme
229  }
230  oDatabase.stop();
231 //check it
232 //TODO fixme!
233 /* for(i=0;i<0x10000;i++)
234  {
235  LP_databaseEntry tmp=oDatabase.m_currDatabase[i];
236  while(tmp!=NULL&&tmp->next!=NULL)
237  {
238  if(memcmp(tmp->key,tmp->next->key,14)>=0)
239  return E_UNKNOWN;
240  tmp=tmp->next;
241  }
242  }*/
243  return E_SUCCESS;
244  }

References E_SUCCESS, getRandom(), insert(), start(), and stop().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ replaydb_loopMaintenance

THREAD_RETURN replaydb_loopMaintenance ( void *  param)
friend

Definition at line 175 of file CAReplayDatabase.cpp.

176  {
177  INIT_STACK;
178  BEGIN_STACK("CADatabase::db_loopMaintenance");
179 
180  CAReplayDatabase* pDatabase=(CAReplayDatabase*)param;
181  tReplayTimestamp rt;
182  pDatabase->getCurrentReplayTimestamp(rt);
183  pDatabase->m_currentClock=rt.interval;
184  while(pDatabase->m_bRun)
185  {
186  sSleep(10);
187  SINT32 secondsTilNextClock=((pDatabase->m_currentClock+1)*SECONDS_PER_INTERVALL)+pDatabase->m_refTime-time(NULL);
188  if(secondsTilNextClock<=0&&pDatabase->m_bRun)
189  pDatabase->nextClock();
190  }
191 
192  FINISH_STACK("CADatabase::db_loopMaintenance");
193 
195  }
#define INIT_STACK
Definition: CAThread.hpp:48
#define BEGIN_STACK(methodName)
Definition: CAThread.hpp:49
#define FINISH_STACK(methodName)
Definition: CAThread.hpp:50
SINT32 sSleep(UINT32 sec)
Sleeps sec Seconds.
Definition: CAUtil.cpp:425
#define THREAD_RETURN_SUCCESS
Definition: StdAfx.h:542

Referenced by start().

Member Data Documentation

◆ m_bRun

volatile bool CAReplayDatabase::m_bRun
private

Definition at line 158 of file CAReplayDatabase.hpp.

Referenced by start(), and stop().

◆ m_currDatabase

t_replay_databaseInfo* CAReplayDatabase::m_currDatabase
private

◆ m_currentClock

volatile SINT32 CAReplayDatabase::m_currentClock
private

◆ m_nextDatabase

t_replay_databaseInfo* CAReplayDatabase::m_nextDatabase
private

◆ m_pMutex

CAMutex* CAReplayDatabase::m_pMutex
private

◆ m_prevDatabase

t_replay_databaseInfo* CAReplayDatabase::m_prevDatabase
private

◆ m_pThread

CAThread* CAReplayDatabase::m_pThread
private

Definition at line 162 of file CAReplayDatabase.hpp.

Referenced by CAReplayDatabase(), start(), and stop().

◆ m_refTime

UINT32 CAReplayDatabase::m_refTime
private

Definition at line 159 of file CAReplayDatabase.hpp.

Referenced by CAReplayDatabase(), getCurrentReplayTimestamp(), and getRefTime().


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