KjTimer.cpp

Go to the documentation of this file.
00001 
00013 #include "KjTimer.h"
00014 
00015 KjTimer::KjTimer()
00016 {
00017         StartTimer();
00018 }
00019 
00020 KjTimer::~KjTimer()
00021 {
00022 }
00023 
00024 void KjTimer::StartTimer()
00025 {
00026         gettimeofday(&m_tStart, &m_tZone);
00027 }
00028 
00029 void KjTimer::StopTimer()
00030 {
00031         gettimeofday(&m_tStop, &m_tZone);
00032 }
00033 
00035 void KjTimer::Wait(const int _iMilisecond)
00036 {
00037         StartTimer();
00038         // Wait until _iMilisecond is greater then time delay
00039         for(;;)
00040         {
00041                 StopTimer();
00042                 time_t tStartSec = m_tStart.tv_sec;
00043                 suseconds_t tStartMicrosec = m_tStart.tv_usec;
00044                 double dStartMilisecond = tStartMicrosec * 0.000001;
00045                 double dStartSec = (double) tStartSec + dStartMilisecond;
00046                 time_t tStopSec = m_tStop.tv_sec;
00047                 suseconds_t tStopMicrosec = m_tStop.tv_usec;
00048                 double dStopMilisecond = tStopMicrosec * 0.000001;
00049                 double dStopSec = (double) tStopSec + dStopMilisecond;
00050                 double dTimeDelayMilisec = (dStopSec - dStartSec)*1000;
00051                 //cout << "dTimeDelayMilisec = " << dTimeDelayMilisec << endl;
00052                 // Stop waiting if _iMilisecond is greater then time delay
00053                 if(dTimeDelayMilisec > _iMilisecond)
00054                 {
00055                         return;
00056                 }
00057         }
00058 }
00059 
00060 
00061 

Generated on Tue Jul 24 10:03:19 2007 for KjSslSocket by  doxygen 1.4.6