summaryrefslogtreecommitdiff
path: root/src/mongo/db/clientcursor.h
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2012-04-29 19:55:45 -0700
committerAaron <aaron@10gen.com>2012-05-05 11:04:06 -0700
commitbfaff395710f25937141fcbfc9f1c062a1ae251d (patch)
tree7907e38e0545f76af1f526e25ca60d55cc3015a7 /src/mongo/db/clientcursor.h
parent11491b034fd9d65356e548ba85659fef8e83d2f3 (diff)
downloadmongo-bfaff395710f25937141fcbfc9f1c062a1ae251d.tar.gz
Reorganize ClientCursor::Pin a bit.
Diffstat (limited to 'src/mongo/db/clientcursor.h')
-rw-r--r--src/mongo/db/clientcursor.h23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h
index f6ee59bc637..d638fcb5272 100644
--- a/src/mongo/db/clientcursor.h
+++ b/src/mongo/db/clientcursor.h
@@ -87,18 +87,7 @@ namespace mongo {
had a bug, it could (or perhaps some sort of attack situation).
*/
class Pin : boost::noncopyable {
- CursorId _cursorid;
public:
- ClientCursor *c() const { return ClientCursor::find( _cursorid ); }
- void release() {
- ClientCursor *cursor = c();
- _cursorid = INVALID_CURSOR_ID;
- if ( cursor ) {
- verify( cursor->_pinValue >= 100 );
- cursor->_pinValue -= 100;
- }
- }
- ~Pin() { DESTRUCTOR_GUARD( release(); ) }
Pin( long long cursorid ) :
_cursorid( INVALID_CURSOR_ID ) {
recursive_scoped_lock lock( ccmutex );
@@ -110,6 +99,18 @@ namespace mongo {
_cursorid = cursorid;
}
}
+ void release() {
+ ClientCursor *cursor = c();
+ _cursorid = INVALID_CURSOR_ID;
+ if ( cursor ) {
+ verify( cursor->_pinValue >= 100 );
+ cursor->_pinValue -= 100;
+ }
+ }
+ ~Pin() { DESTRUCTOR_GUARD( release(); ) }
+ ClientCursor *c() const { return ClientCursor::find( _cursorid ); }
+ private:
+ CursorId _cursorid;
};
/** Assures safe and reliable cleanup of a ClientCursor. */