reSIProcate/stack  9694
Classes | Defines | Functions
testAppTimer.cxx File Reference
#include <iostream>
#include "resip/stack/TransactionMessage.hxx"
#include "resip/stack/TimerQueue.hxx"
#include "resip/stack/TuSelector.hxx"
#include "rutil/Fifo.hxx"
#include "rutil/Logger.hxx"
#include <unistd.h>
Include dependency graph for testAppTimer.cxx:

Go to the source code of this file.

Classes

class  AppMessage

Defines

#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Functions

bool isNear (int value, int reference, int epsilon=250)
int main (int argc, char **argv)

Define Documentation

#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Definition at line 18 of file testAppTimer.cxx.


Function Documentation

bool isNear ( int  value,
int  reference,
int  epsilon = 250 
)

Definition at line 24 of file testAppTimer.cxx.

Referenced by main().

{
   int diff = ::abs(value-reference);
   return (diff < epsilon);
}
int main ( int  argc,
char **  argv 
)

Definition at line 55 of file testAppTimer.cxx.

References resip::BaseTimeLimitTimerQueue::add(), resip::Log::Cout, resip::Log::Debug, resip::TimeLimitFifo< Msg >::getNext(), resip::Log::initialize(), resip::TimerQueue< T >::msTillNextTimer(), resip::TimerQueue< T >::process(), and resip::AbstractFifo< T >::size().

{
   Log::initialize(Log::Cout, Log::Debug, argv[0]);

   TimeLimitFifo<Message> f(0, 0);
   TimeLimitTimerQueue timer(f);

   cerr << "Before Fifo size: " << f.size() << endl;
   assert(f.size() == 0);
   cerr << "next timer = " << timer.msTillNextTimer() << endl;
   assert(timer.msTillNextTimer() == INT_MAX);

   timer.add(1000, new AppMessage("first"));
   cerr << timer;
   assert(f.size() == 0);
   timer.process();
   cerr << "Immediately after Fifo size: " << f.size() << endl;
   assert(f.size() == 0);

   sleep(1);
   timer.process();
   assert(f.size() == 1);

   Message* msg = f.getNext();

   cerr << *msg << endl;

   delete msg;
   return 0;
}

Here is the call graph for this function: