reSIProcate/rutil  9694
Public Member Functions | Static Public Member Functions | Protected Attributes
TestRandomThread Class Reference
Inheritance diagram for TestRandomThread:
Inheritance graph
[legend]
Collaboration diagram for TestRandomThread:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TestRandomThread (int runs, Barrier &barrier, int storeBytes)
 ~TestRandomThread ()
virtual void thread ()
void makeAndStoreRandoms (int numCycles)
const DataSetgetRandoms () const
int getDupCnt () const

Static Public Member Functions

static void makeRandoms (int numCycles)

Protected Attributes

int mNumRuns
BarriermBarrier
int mStoreBytes
DataSet mRandoms
int mDupCnt

Detailed Description

Definition at line 82 of file testRandomThread.cxx.


Constructor & Destructor Documentation

TestRandomThread::TestRandomThread ( int  runs,
Barrier barrier,
int  storeBytes 
) [inline]

Definition at line 85 of file testRandomThread.cxx.

         : mNumRuns(runs), mBarrier(barrier), mStoreBytes(storeBytes),
         mDupCnt(0)
      { };
TestRandomThread::~TestRandomThread ( ) [inline]

Definition at line 89 of file testRandomThread.cxx.

{ };

Member Function Documentation

int TestRandomThread::getDupCnt ( ) const [inline]

Definition at line 95 of file testRandomThread.cxx.

Referenced by doThreadedTest().

{ return mDupCnt; }
const DataSet& TestRandomThread::getRandoms ( ) const [inline]

Definition at line 94 of file testRandomThread.cxx.

Referenced by doThreadedTest().

{ return mRandoms; };
void TestRandomThread::makeAndStoreRandoms ( int  numCycles)

Definition at line 121 of file testRandomThread.cxx.

References RANDSEQ_PER_CYCLE.

{
   int idx, cidx;
   for (cidx=0; cidx < numCycles; cidx++)
   {
      for (idx = 0; idx < RANDSEQ_PER_CYCLE; idx++)
      {
         Data foo = Random::getRandomHex(mStoreBytes);
         if (mRandoms.insert(foo).second == false )
         {
            ++mDupCnt;
            // std::cerr << "RandomHex produced intra-thread duplicate after " 
            //   << idx << " calls."<<std::endl;
         }
      }
   }
}
void TestRandomThread::makeRandoms ( int  numCycles) [static]

Definition at line 107 of file testRandomThread.cxx.

References RANDINT_PER_CYCLE.

Referenced by doSingleTest().

{
   int idx, cidx;
   for (cidx=0; cidx < numCycles; cidx++)
   {
      for (idx = 0; idx < RANDINT_PER_CYCLE; idx++)
      {
         int val = Random::getRandom();
         (void)val;
      }
   }
}
void TestRandomThread::thread ( ) [virtual]

Implements resip::ThreadIf.

Definition at line 141 of file testRandomThread.cxx.

{
   // do once to get over initialization
   Random::getRandom();
   // std::cerr << "Thread initialized." << std::endl;

   mBarrier.sync(1);

   if (mStoreBytes == 0 )
   {
      makeRandoms(mNumRuns);
   }
   else
   {
      makeAndStoreRandoms(mNumRuns);
   }

   mBarrier.sync(2);
}

Member Data Documentation

Definition at line 99 of file testRandomThread.cxx.

int TestRandomThread::mDupCnt [protected]

Definition at line 102 of file testRandomThread.cxx.

int TestRandomThread::mNumRuns [protected]

Definition at line 98 of file testRandomThread.cxx.

Definition at line 101 of file testRandomThread.cxx.

Definition at line 100 of file testRandomThread.cxx.


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