diff options
author | Mathias Stearn <mathias@10gen.com> | 2013-11-22 16:47:11 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2013-11-22 16:47:11 -0500 |
commit | f267bf1ff81e02185ef2a316aefa31c6459234f9 (patch) | |
tree | ce2325d4ac84d702a46964a12a41e3ffdaaa9656 /src/mongo | |
parent | 0b4202bb531dbdccd87215396ccb3726f55c1421 (diff) | |
download | mongo-f267bf1ff81e02185ef2a316aefa31c6459234f9.tar.gz |
SERVER-10566 Don't use modulus in ElapsedTracker
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/util/elapsed_tracker.cpp | 5 | ||||
-rw-r--r-- | src/mongo/util/elapsed_tracker.h | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/util/elapsed_tracker.cpp b/src/mongo/util/elapsed_tracker.cpp index 07f72598f02..becbdda1cae 100644 --- a/src/mongo/util/elapsed_tracker.cpp +++ b/src/mongo/util/elapsed_tracker.cpp @@ -44,13 +44,15 @@ namespace mongo { } bool ElapsedTracker::intervalHasElapsed() { - if ( ( ++_pings % _hitsBetweenMarks ) == 0 ) { + if ( ++_pings >= _hitsBetweenMarks ) { + _pings = 0; _last = Listener::getElapsedTimeMillis(); return true; } long long now = Listener::getElapsedTimeMillis(); if ( now - _last > _msBetweenMarks ) { + _pings = 0; _last = now; return true; } @@ -59,6 +61,7 @@ namespace mongo { } void ElapsedTracker::resetLastTime() { + _pings = 0; _last = Listener::getElapsedTimeMillis(); } diff --git a/src/mongo/util/elapsed_tracker.h b/src/mongo/util/elapsed_tracker.h index b2460cc66d9..90e02fdb09a 100644 --- a/src/mongo/util/elapsed_tracker.h +++ b/src/mongo/util/elapsed_tracker.h @@ -51,7 +51,7 @@ namespace mongo { const int32_t _hitsBetweenMarks; const int32_t _msBetweenMarks; - uint64_t _pings; + int32_t _pings; int64_t _last; }; |