#include <ELmap.h>
Public Member Functions | |
bool | add () |
CountAndLimit (int lim=-1, int ts=-1, int ivl=-1) | |
Public Attributes | |
int | aggregateN |
int | interval |
time_t | lastTime |
int | limit |
int | n |
int | skipped |
int | timespan |
edm::CountAndLimit::CountAndLimit | ( | int | lim = -1 , |
int | ts = -1 , |
||
int | ivl = -1 |
||
) |
bool edm::CountAndLimit::add | ( | ) |
Definition at line 58 of file ELmap.cc.
References aggregateN, dtNoiseDBValidation_cfg::cerr, diffTreeTool::diff, interval, lastTime, limit, n, cmsPerfSuiteHarvest::now, alignCSCRings::r, skipped, cond::rpcobgas::time, and timespan.
{ time_t now = time(0); #ifdef ELcountTRACE std::cerr << "&&&--- CountAndLimit::add \n"; std::cerr << "&&& Time now is " << now << "\n"; std::cerr << "&&& Last time is " << lastTime << "\n"; std::cerr << "&&& timespan is " << timespan << "\n"; std::cerr << "&&& difftime is " << difftime( now, lastTime ) << "\n" << std::flush; #endif // Has it been so long that we should restart counting toward the limit? if ( (timespan >= 0) && (difftime(now, lastTime) >= timespan) ) { n = 0; if ( interval > 0 ) { skipped = interval - 1; // So this message will be reacted to } else { skipped = 0; } } lastTime = now; ++n; ++aggregateN; ++skipped; #ifdef ELcountTRACE std::cerr << "&&& n is " << n << "-- limit is " << limit << "\n"; std::cerr << "&&& skipped is " << skipped << "-- interval is " << interval << "\n"; #endif if (skipped < interval) return false; if ( limit == 0 ) return false; // Zero limit - never react to this if ( (limit < 0) || ( n <= limit )) { skipped = 0; return true; } // Now we are over the limit - have we exceeded limit by 2^N * limit? long diff = n - limit; long r = diff/limit; if ( r*limit != diff ) { // Not a multiple of limit - don't react return false; } if ( r == 1 ) { // Exactly twice limit - react skipped = 0; return true; } while ( r > 1 ) { if ( (r & 1) != 0 ) return false; // Not 2**n times limit - don't react r >>= 1; } // If you never get an odd number till one, r is 2**n so react skipped = 0; return true; } // add()
time_t edm::CountAndLimit::lastTime |