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

#include <CAFirstMix.hpp>

Collaboration diagram for CAFirstMixChannelToQueueList:

Public Member Functions

 CAFirstMixChannelToQueueList ()
 
SINT32 add (HCHANNEL channel, CAQueue *pQueue)
 
CAQueueget (HCHANNEL channel)
 
SINT32 removeChannel (HCHANNEL channel)
 
void performanceTest ()
 

Private Attributes

CAMutexm_pMutex
 
tFirstMixChannelToQueueListEntry ** m_pHeads
 

Detailed Description

Definition at line 123 of file CAFirstMix.hpp.

Constructor & Destructor Documentation

◆ CAFirstMixChannelToQueueList()

CAFirstMixChannelToQueueList::CAFirstMixChannelToQueueList ( )
inline

Definition at line 126 of file CAFirstMix.hpp.

127  {
128  m_pMutex = new CAMutex();
130  memset(m_pHeads, 0, sizeof(t_FirstMixChannelToQueueList_entry*) * 0x10000);
131  }
tFirstMixChannelToQueueListEntry ** m_pHeads
Definition: CAFirstMix.hpp:225
Definition: CAFirstMix.hpp:115

References m_pHeads, and m_pMutex.

Member Function Documentation

◆ add()

SINT32 CAFirstMixChannelToQueueList::add ( HCHANNEL  channel,
CAQueue pQueue 
)
inline

Definition at line 133 of file CAFirstMix.hpp.

134  {
135  m_pMutex->lock();
137  pNewEntry->channel = channel;
138  pNewEntry->pQueue = pQueue;
139  UINT32 hashkey = channel & 0x0FFFF;
140  pNewEntry->next = m_pHeads[hashkey];
141  m_pHeads[hashkey] = pNewEntry;
142  m_pMutex->unlock();
143  return E_SUCCESS;
144  }
struct t_FirstMixChannelToQueueList_entry tFirstMixChannelToQueueListEntry
unsigned int UINT32
Definition: basetypedefs.h:131
SINT32 unlock()
Definition: CAMutex.hpp:52
SINT32 lock()
Definition: CAMutex.hpp:41
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
HCHANNEL channel
Definition: CAFirstMix.hpp:116
t_FirstMixChannelToQueueList_entry * next
Definition: CAFirstMix.hpp:118
CAQueue * pQueue
Definition: CAFirstMix.hpp:117
HCHANNEL channel
Definition: typedefs.hpp:0

References t_FirstMixChannelToQueueList_entry::channel, channel, E_SUCCESS, CAMutex::lock(), m_pHeads, m_pMutex, t_FirstMixChannelToQueueList_entry::next, t_FirstMixChannelToQueueList_entry::pQueue, and CAMutex::unlock().

Referenced by performanceTest().

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

◆ get()

CAQueue* CAFirstMixChannelToQueueList::get ( HCHANNEL  channel)
inline

Definition at line 146 of file CAFirstMix.hpp.

147  {
148 #ifndef LOCK_FREE_LIST
149  m_pMutex->lock();
150 #endif
151  tFirstMixChannelToQueueListEntry* pEntry = m_pHeads[channel & 0x0FFFF ];
152  while (pEntry != NULL)
153  {
154  if (pEntry->channel == channel)
155  {
156  CAQueue* pQueue = pEntry->pQueue;
157 #ifndef LOCK_FREE_LIST
158  m_pMutex->unlock();
159 #endif
160  return pQueue;
161  }
162  pEntry=pEntry->next;
163  }
164 #ifndef LOCK_FREE_LIST
165  m_pMutex->unlock();
166 #endif
167  return NULL;
168  }
This is a simple FIFO-Queue.
Definition: CAQueue.hpp:50

References t_FirstMixChannelToQueueList_entry::channel, channel, CAMutex::lock(), m_pHeads, m_pMutex, t_FirstMixChannelToQueueList_entry::next, t_FirstMixChannelToQueueList_entry::pQueue, and CAMutex::unlock().

Referenced by performanceTest().

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

◆ performanceTest()

void CAFirstMixChannelToQueueList::performanceTest ( )
inline

Definition at line 197 of file CAFirstMix.hpp.

198  {
199  UINT32 nrChannels = 10000;
200  UINT32 nrAccess = 10000000;
201  HCHANNEL* pChannels = new HCHANNEL[nrChannels];
202  printf("%u Channel test - %u accesses\n",nrChannels,nrAccess);
203  for (UINT32 i = 0; i < nrChannels; i++)
204  {
205  getRandom(&pChannels[i]);
206  add(pChannels[i], NULL);
207  }
208 
209  UINT64 startTime;
210  getcurrentTimeMillis(startTime);
211  for (UINT32 i = 0; i < nrAccess; i++)
212  {
213  UINT32 r;
214  getRandom(&r);
215  r %= 10000;
216  get(pChannels[r]);
217  }
218  UINT64 endTime;
219  getcurrentTimeMillis(endTime);
220 
221  printf("Duration: %u ms\n", diff64(endTime, startTime));
222  }
SINT32 getcurrentTimeMillis(UINT64 &u64Time)
Gets the current Systemtime in milli seconds.
Definition: CAUtil.cpp:252
SINT32 getRandom(UINT32 *val)
Gets 32 random bits.
Definition: CAUtil.cpp:346
UINT32 diff64(const UINT64 &bigop, const UINT64 &smallop)
Definition: CAUtil.hpp:398
SINT32 add(HCHANNEL channel, CAQueue *pQueue)
Definition: CAFirstMix.hpp:133
CAQueue * get(HCHANNEL channel)
Definition: CAFirstMix.hpp:146
UINT32 HCHANNEL
Definition: typedefs.hpp:34

References add(), diff64(), get(), getcurrentTimeMillis(), and getRandom().

Here is the call graph for this function:

◆ removeChannel()

SINT32 CAFirstMixChannelToQueueList::removeChannel ( HCHANNEL  channel)
inline

Definition at line 170 of file CAFirstMix.hpp.

171  {
172  m_pMutex->lock();
174  tFirstMixChannelToQueueListEntry* pLastEntry = NULL;
175  while (pEntry != NULL)
176  {
177  if (pEntry->channel == channel)
178  {
179  if (pLastEntry != NULL)
180  {
181  pLastEntry->next = pEntry->next;
182  }
183  else
184  {
185  m_pHeads[channel & 0x0FFFF] = pEntry->next;
186  }
187  delete pEntry;
188  m_pMutex->unlock();
189  return E_SUCCESS;
190  }
191  pEntry=pEntry->next;
192  }
193  m_pMutex->unlock();
194  return E_UNKNOWN;
195  }
#define E_UNKNOWN
Definition: errorcodes.hpp:3

References t_FirstMixChannelToQueueList_entry::channel, channel, E_SUCCESS, E_UNKNOWN, CAMutex::lock(), m_pHeads, m_pMutex, t_FirstMixChannelToQueueList_entry::next, and CAMutex::unlock().

Here is the call graph for this function:

Member Data Documentation

◆ m_pHeads

tFirstMixChannelToQueueListEntry** CAFirstMixChannelToQueueList::m_pHeads
private

Definition at line 225 of file CAFirstMix.hpp.

Referenced by add(), CAFirstMixChannelToQueueList(), get(), and removeChannel().

◆ m_pMutex

CAMutex* CAFirstMixChannelToQueueList::m_pMutex
private

Definition at line 224 of file CAFirstMix.hpp.

Referenced by add(), CAFirstMixChannelToQueueList(), get(), and removeChannel().


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