Public Member Functions | Static Public Member Functions

mozilla::TimeStamp Class Reference

Instances of this class represent moments in time, or a special "null" moment. More...

#include <TimeStamp.h>

List of all members.

Public Member Functions

 TimeStamp ()
 Initialize to the "null" moment.
PRBool IsNull () const
 Return true if this is the "null" moment.
TimeDuration operator- (const TimeStamp &aOther) const
 Compute the difference between two timestamps.
TimeStamp operator+ (const TimeDuration &aOther) const
TimeStamp operator- (const TimeDuration &aOther) const
TimeStampoperator+= (const TimeDuration &aOther)
TimeStampoperator-= (const TimeDuration &aOther)
PRBool operator< (const TimeStamp &aOther) const
PRBool operator<= (const TimeStamp &aOther) const
PRBool operator>= (const TimeStamp &aOther) const
PRBool operator> (const TimeStamp &aOther) const
PRBool operator== (const TimeStamp &aOther) const
PRBool operator!= (const TimeStamp &aOther) const

Static Public Member Functions

static TimeStamp Now ()
 Return a timestamp reflecting the current elapsed system time.
static nsresult Startup ()
static void Shutdown ()

Detailed Description

Instances of this class represent moments in time, or a special "null" moment.

We do not use the non-monotonic system clock or local time, since they can be reset, causing apparent backward travel in time, which can confuse algorithms. Instead we measure elapsed time according to the system. This time can never go backwards (i.e. it never wraps around, at least not in less than five million years of system elapsed time). It might not advance while the system is sleeping. If TimeStamp::SetNow() is not called at all for hours or days, we might not notice the passage of some of that time.

We deliberately do not expose a way to convert TimeStamps to some particular unit. All you can do is compute a difference between two TimeStamps to get a TimeDuration. You can also add a TimeDuration to a TimeStamp to get a new TimeStamp. You can't do something meaningless like add two TimeStamps.

Internally this is implemented as either a wrapper around


Constructor & Destructor Documentation

mozilla::TimeStamp::TimeStamp (  )  [inline]

Initialize to the "null" moment.


Member Function Documentation

PRBool mozilla::TimeStamp::IsNull (  )  const [inline]

Return true if this is the "null" moment.

static TimeStamp mozilla::TimeStamp::Now (  )  [static]

Return a timestamp reflecting the current elapsed system time.

This is monotonically increasing (i.e., does not decrease) over the lifetime of this process' XPCOM session.

PRBool mozilla::TimeStamp::operator!= ( const TimeStamp aOther  )  const [inline]
TimeStamp mozilla::TimeStamp::operator+ ( const TimeDuration aOther  )  const [inline]
TimeStamp& mozilla::TimeStamp::operator+= ( const TimeDuration aOther  )  [inline]
TimeStamp mozilla::TimeStamp::operator- ( const TimeDuration aOther  )  const [inline]
TimeDuration mozilla::TimeStamp::operator- ( const TimeStamp aOther  )  const [inline]

Compute the difference between two timestamps.

Both must be non-null.

TimeStamp& mozilla::TimeStamp::operator-= ( const TimeDuration aOther  )  [inline]
PRBool mozilla::TimeStamp::operator< ( const TimeStamp aOther  )  const [inline]
PRBool mozilla::TimeStamp::operator<= ( const TimeStamp aOther  )  const [inline]
PRBool mozilla::TimeStamp::operator== ( const TimeStamp aOther  )  const [inline]
PRBool mozilla::TimeStamp::operator> ( const TimeStamp aOther  )  const [inline]
PRBool mozilla::TimeStamp::operator>= ( const TimeStamp aOther  )  const [inline]
static void mozilla::TimeStamp::Shutdown (  )  [static]
static nsresult mozilla::TimeStamp::Startup (  )  [static]

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