00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARCHON_UTILITIES_ADAPTIVE_SKIP_H
00021 #define ARCHON_UTILITIES_ADAPTIVE_SKIP_H
00022
00023
00024 #include <string>
00025
00026 #include <archon/util/exception.H>
00027
00028 namespace Archon
00029 {
00030 namespace Utilities
00031 {
00032 struct AdaptiveSkip
00033 {
00034 AdaptiveSkip(unsigned long millisBetweenOutTicks,
00035 unsigned long checksPerOutTick = 10);
00036 bool tick() { return ++skippedTicks == ticksPerCheck && check(); }
00037
00038 protected:
00039 unsigned long timeOfLastCheck;
00040 unsigned long timeOfLastOutTick;
00041
00042 private:
00043 unsigned long millisBetweenOutTicks;
00044 unsigned long checksPerOutTick;
00045 unsigned long skippedTicks;
00046 unsigned long ticksPerCheck;
00047
00048 unsigned long getTimeInMilliSeconds();
00049 bool check();
00050 };
00051 }
00052 }
00053
00054 #endif // ARCHON_UTILITIES_ADAPTIVE_SKIP_H