Example #1
0
 /* call when cursor's location changes so that we can update the
    cursorsbylocation map.  if you are locked and internally iterating, only
    need to call when you are ready to "unlock".
 */
 void ClientCursor::updateLocation() {
     verify( _cursorid );
     _idleAgeMillis = 0;
     _c->prepareToYield();
     DiskLoc cl = _c->refLoc();
     if ( lastLoc() == cl ) {
         //log() << "info: lastloc==curloc " << ns << '\n';
     }
     else {
         recursive_scoped_lock lock(ccmutex);
         setLastLoc_inlock(cl);
     }
 }
Example #2
0
 /* call when cursor's location changes so that we can update the
    cursorsbylocation map.  if you are locked and internally iterating, only
    need to call when you are ready to "unlock".
 */
 void ClientCursor::updateLocation() {
     assert( cursorid );
     _idleAgeMillis = 0;
     DiskLoc cl = c->refLoc();
     if ( lastLoc() == cl ) {
         //log() << "info: lastloc==curloc " << ns << '\n';
     } else {
         recursive_scoped_lock lock(ccmutex);
         setLastLoc_inlock(cl);
     }
     // may be necessary for MultiCursor even when cl hasn't changed
     c->noteLocation();
 }
Example #3
0
    ClientCursor::~ClientCursor() {
        assert( pos != -2 );

        {
            recursive_scoped_lock lock(ccmutex);
            setLastLoc_inlock( DiskLoc() ); // removes us from bylocation multimap
            clientCursorsById.erase(cursorid);

            // defensive:
            (CursorId&) cursorid = -1;
            pos = -2;
        }
    }
Example #4
0
    ClientCursor::~ClientCursor() {
        if( _pos == -2 ) {
            // defensive: destructor called twice
            wassert(false);
            return;
        }

        {
            recursive_scoped_lock lock(ccmutex);
            setLastLoc_inlock( DiskLoc() ); // removes us from bylocation multimap
            clientCursorsById.erase(_cursorid);

            // defensive:
            (CursorId&)_cursorid = -1;
            _pos = -2;
        }
    }
Example #5
0
    ClientCursor::~ClientCursor() {
        if( _pos == -2 ) {
            // defensive: destructor called twice
            wassert(false);
            return;
        }

        {
            recursive_scoped_lock lock(ccmutex);
            if (NULL != _c.get()) {
                // Removes 'this' from bylocation map
                setLastLoc_inlock( DiskLoc() );
            }

            clientCursorsById.erase(_cursorid);

            // defensive:
            _cursorid = INVALID_CURSOR_ID;
            _pos = -2;
            _pinValue = 0;
        }
    }