Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

TimeStampedEvent.hh File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Compounds

class  TimeStampedEvent
struct  TimeStamper

Typedefs

typedef TimeStamper< unsigned
long int > 
DefaultTimeStamper


Detailed Description

Class definition file.

Copyright:

Copyright (C) 2002, 2003 Oliver Schoenborn

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

You can redistribute it and/or modify it under the terms found in the LICENSE file that is included in the library distribution.

Definition in file TimeStampedEvent.hh.


Typedef Documentation

typedef TimeStamper<unsigned long int> DefaultTimeStamper
 

Default time stamper just uses a counter of type unsigned long int. It has the benefit of

  • complete portability
  • speed
  • garantee of unique stamp for every event
Time stampers that rely on system clocks typically suffer in all three areas: the call is relatively costly, several events may end up with the same time stamp, the system clock may provide different resolutions on different systems, and may not be accessible with the same system calls.

The only disadvantage is that the time stamp will cycle every 2^N events, where N is the number of bits for the long int data type. Consequences:

  • 32-bit longs:
    • over 4 billion events before rollover;
    • one million time-stamped events/second implies a rollover every hour;
    • therefore a program generating 1 million time-stamped events/sec (not all event types need be time-stamped in your program) would have to run uninterrupted for more than one hour in order to see the rollover;
  • 64-bit longs:
    • 20 billion billion events (2x10^19) before rollover;
    • one billion time-stamped events/second implies a rollover every 700 years;
    • therefore a program generating 1 billion time-stamped events/sec would have to run uninterrupted for more than 700 years in order to see the rollover.
If this limitation is not acceptable, you have two choices:
  • Create your own integer-based time-stamper, via a new class or a specialization of TimeStamper<IntType>, with an integer type that garantees enough bits (e.g., certain libraries provide a class where the number of bits is specified via a template parameter, e.g. Int<128>, or perhaps the Standard will eventually supply int64 and int128);
  • Create your own generic time-stamper via a new class, and define the appropriate members (DataType, getTimeStamp(), and leftOlder()).

Definition at line 102 of file TimeStampedEvent.hh.


Generated on Sun Feb 16 16:56:24 2003 for C++ Event Handling Template Library by doxygen1.2.18