Пример #1
0
 /*static*/ OpTime OpTime::_now() {
     OpTime result;
     unsigned t = (unsigned) time(0);
     if ( last.secs == t ) {
         last.i++;
         result = last;
     }
     else if ( t < last.secs ) {
         result = skewed(); // separate function to keep out of the hot code path
     }
     else { 
         last = OpTime(t, 1);
         result = last;
     }
     notifier.notify_all();
     return last;
 }
Пример #2
0
Timestamp getNextGlobalTimestamp() {
    stdx::lock_guard<stdx::mutex> lk(globalTimestampMutex);

    const unsigned now = (unsigned)time(0);
    const unsigned globalSecs = globalTimestamp.getSecs();
    if (globalSecs == now) {
        globalTimestamp = Timestamp(globalSecs, globalTimestamp.getInc() + 1);
    } else if (now < globalSecs) {
        globalTimestamp = Timestamp(globalSecs, globalTimestamp.getInc() + 1);
        // separate function to keep out of the hot code path
        fassert(17449, !skewed(globalTimestamp));
    } else {
        globalTimestamp = Timestamp(now, 1);
    }

    return globalTimestamp;
}