BasicUsageEnvironment/DelayQueue.cpp File Reference

#include "DelayQueue.hh"
#include "GroupsockHelper.hh"

Include dependency graph for DelayQueue.cpp:

Go to the source code of this file.

Defines

#define INT_MAX   0x7FFFFFFF

Functions

DelayInterval operator- (const Timeval &arg1, const Timeval &arg2)
DelayInterval operator * (short arg1, const DelayInterval &arg2)
EventTime TimeNow ()
DelayInterval TimeRemainingUntil (const EventTime &futureEvent)

Variables

static const int MILLION = 1000000
const DelayInterval DELAY_ZERO (0, 0)
const DelayInterval DELAY_SECOND (1, 0)
const DelayInterval ETERNITY (INT_MAX, MILLION-1)
const EventTime THE_END_OF_TIME (INT_MAX)


Define Documentation

#define INT_MAX   0x7FFFFFFF

Definition at line 81 of file DelayQueue.cpp.


Function Documentation

DelayInterval operator * ( short  arg1,
const DelayInterval arg2 
)

Definition at line 69 of file DelayQueue.cpp.

References MILLION, Timeval::seconds(), and Timeval::useconds().

00069                                                                {
00070   time_base_seconds result_seconds = arg1*arg2.seconds();
00071   time_base_seconds result_useconds = arg1*arg2.useconds();
00072 
00073   time_base_seconds carry = result_useconds/MILLION;
00074   result_useconds -= carry*MILLION;
00075   result_seconds += carry;
00076 
00077   return DelayInterval(result_seconds, result_useconds);
00078 }

DelayInterval operator- ( const Timeval arg1,
const Timeval arg2 
)

Definition at line 52 of file DelayQueue.cpp.

References DELAY_ZERO, MILLION, Timeval::seconds(), Timeval::secs(), Timeval::useconds(), and Timeval::usecs().

00052                                                                   {
00053   time_base_seconds secs = arg1.seconds() - arg2.seconds();
00054   time_base_seconds usecs = arg1.useconds() - arg2.useconds();
00055 
00056   if (usecs < 0) {
00057     usecs += MILLION;
00058     --secs;
00059   }
00060   if (secs < 0)
00061     return DELAY_ZERO;
00062   else
00063     return DelayInterval(secs, usecs);
00064 }

EventTime TimeNow (  ) 

Definition at line 212 of file DelayQueue.cpp.

References NULL.

Referenced by DelayQueue::DelayQueue(), DelayQueue::synchronize(), and TimeRemainingUntil().

00212                     {
00213   struct timeval tvNow;
00214 
00215   gettimeofday(&tvNow, NULL);
00216 
00217   return EventTime(tvNow.tv_sec, tvNow.tv_usec);
00218 }

DelayInterval TimeRemainingUntil ( const EventTime futureEvent  ) 

Definition at line 220 of file DelayQueue.cpp.

References TimeNow().

00220                                                                {
00221   return futureEvent - TimeNow();
00222 }


Variable Documentation

const DelayInterval DELAY_SECOND(1, 0)

const DelayInterval DELAY_ZERO(0, 0)

Referenced by DelayQueue::handleAlarm(), operator-(), DelayQueue::synchronize(), and DelayQueue::timeToNextAlarm().

const DelayInterval ETERNITY(INT_MAX, MILLION-1)

const int MILLION = 1000000 [static]

Definition at line 24 of file DelayQueue.cpp.

const EventTime THE_END_OF_TIME(INT_MAX)


Generated on Tue Oct 7 15:38:11 2008 for live by  doxygen 1.5.2