summaryrefslogtreecommitdiff
path: root/src/mongo/util/time_support.h
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2012-07-05 15:05:10 -0400
committerGreg Studer <greg@10gen.com>2012-07-30 16:07:09 -0400
commit424df087f9256b85e7b3a9b31d36518081ff2875 (patch)
treeaba2fe1e3204be9f1bf282aa108c0ae918cfa357 /src/mongo/util/time_support.h
parent3ac0e57723cd6169e305b6795b686ec45b2d4b83 (diff)
downloadmongo-424df087f9256b85e7b3a9b31d36518081ff2875.tar.gz
SERVER-6282 wait-doubling backoff for local mongos errors requiring config server access
Diffstat (limited to 'src/mongo/util/time_support.h')
-rw-r--r--src/mongo/util/time_support.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mongo/util/time_support.h b/src/mongo/util/time_support.h
index 511bc092fb1..254401b01ad 100644
--- a/src/mongo/util/time_support.h
+++ b/src/mongo/util/time_support.h
@@ -43,6 +43,29 @@ namespace mongo {
void sleepmillis(long long ms);
void sleepmicros(long long micros);
+ class Backoff {
+ public:
+
+ Backoff( int maxSleepMillis, int resetAfter ) :
+ _maxSleepMillis( maxSleepMillis ),
+ _resetAfterMillis( maxSleepMillis + resetAfter ), // Don't reset < the max sleep
+ _lastSleepMillis( 0 ),
+ _lastErrorTimeMillis( 0 )
+ {}
+
+ void nextSleepMillis();
+
+ private:
+
+ // Parameters
+ int _maxSleepMillis;
+ int _resetAfterMillis;
+
+ // Last sleep information
+ int _lastSleepMillis;
+ unsigned long long _lastErrorTimeMillis;
+ };
+
// DO NOT TOUCH except for testing
void jsTimeVirtualSkew( long long skew );