예제 #1
0
    bool ClientCursor::yieldSometimes( RecordNeeds need, bool *yielded ) {
        if ( yielded ) {
            *yielded = false;   
        }
        if ( ! _yieldSometimesTracker.intervalHasElapsed() ) {
            Record* rec = _recordForYield( need );
            if ( rec ) {
                // yield for page fault
                if ( yielded ) {
                    *yielded = true;   
                }
                bool res = yield( suggestYieldMicros() , rec );
                if ( res )
                    _yieldSometimesTracker.resetLastTime();
                return res;
            }
            return true;
        }

        int micros = suggestYieldMicros();
        if ( micros > 0 ) {
            if ( yielded ) {
                *yielded = true;   
            }
            bool res = yield( micros , _recordForYield( need ) );
            if ( res ) 
                _yieldSometimesTracker.resetLastTime();
            return res;
        }
        return true;
    }
예제 #2
0
    bool ClientCursor::yieldSometimes( RecordNeeds need ) {
        if ( ! _yieldSometimesTracker.ping() ) {
            Record* rec = _recordForYield( need );
            if ( rec ) 
                return yield( yieldSuggest() , rec );
            return true;
        }

        int micros = yieldSuggest();
        return ( micros > 0 ) ? yield( micros , _recordForYield( need ) ) : true;
    }