Last active
December 23, 2015 07:39
-
-
Save nelhage/6602767 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Excerpted from https://github.com/mongodb/mongo/blob/ea83ad3103fef1664e9385d48537c4163344ce8a/src/mongo/util/debug_util.h#L37 */ | |
// The following declare one unique counter per enclosing function. | |
// NOTE The implementation double-increments on a match, but we don't really care. | |
#define MONGO_SOMETIMES( occasion, howOften ) for( static unsigned occasion = 0; ++occasion % howOften == 0; ) | |
#define SOMETIMES MONGO_SOMETIMES | |
#define MONGO_OCCASIONALLY SOMETIMES( occasionally, 16 ) | |
#define OCCASIONALLY MONGO_OCCASIONALLY | |
#define MONGO_RARELY SOMETIMES( rarely, 128 ) | |
#define RARELY MONGO_RARELY | |
#define MONGO_ONCE for( static bool undone = true; undone; undone = false ) | |
#define ONCE MONGO_ONCE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Excerpted from https://github.com/mongodb/mongo/blob/ea83ad3103fef1664e9385d48537c4163344ce8a/src/mongo/bson/optime.cpp#L32 */ | |
{ | |
bool toLog = false; | |
ONCE toLog = true; | |
RARELY toLog = true; | |
last.i++; | |
if ( last.i & 0x80000000 ) | |
toLog = true; | |
if ( toLog ) { | |
log() << "clock skew detected prev: " << last.secs << " now: " << (unsigned) time(0) | |
<< std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment