Skip to content

Commit

Permalink
Rename ClientCursor pointer classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
astaple committed May 5, 2012
1 parent 6a1df89 commit e5896ba
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
16 changes: 8 additions & 8 deletions src/mongo/db/clientcursor.h
Expand Up @@ -85,7 +85,7 @@ namespace mongo {
at the same time - which might be bad. That should never happen, but if a client driver
had a bug, it could (or perhaps some sort of attack situation).
*/
class Pointer : boost::noncopyable {
class Pin : boost::noncopyable {
ClientCursor *_c;
public:
ClientCursor * c() { return _c; }
Expand All @@ -103,8 +103,8 @@ namespace mongo {
void deleted() {
_c = 0;
}
~Pointer() { release(); }
Pointer(long long cursorid) {
~Pin() { release(); }
Pin(long long cursorid) {
recursive_scoped_lock lock(ccmutex);
_c = ClientCursor::find_inlock(cursorid, true);
if( _c ) {
Expand All @@ -118,9 +118,9 @@ namespace mongo {
};

// This object assures safe and reliable cleanup of a ClientCursor.
class CleanupPointer : boost::noncopyable {
class Holder : boost::noncopyable {
public:
CleanupPointer() : _c( 0 ), _id( -1 ) {}
Holder() : _c( 0 ), _id( -1 ) {}
void reset( ClientCursor *c = 0 ) {
if ( c == _c )
return;
Expand All @@ -137,7 +137,7 @@ namespace mongo {
_id = -1;
}
}
~CleanupPointer() {
~Holder() {
DESTRUCTOR_GUARD ( reset(); );
}
operator bool() { return _c; }
Expand Down Expand Up @@ -445,8 +445,8 @@ namespace mongo {
// release()ed after a yield if stillOk() returns false and these pointer types
// do not support releasing. This will prevent them from being used accidentally
// Instead of auto_ptr<>, which still requires some degree of manual management
// of this, consider using ClientCursor::CleanupPointer which handles
// ClientCursor's unusual self-deletion mechanics
// of this, consider using ClientCursor::Holder which handles ClientCursor's
// unusual self-deletion mechanics.
namespace boost{
template<> class scoped_ptr<mongo::ClientCursor> {};
template<> class shared_ptr<mongo::ClientCursor> {};
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/commands/group.cpp
Expand Up @@ -88,7 +88,7 @@ namespace mongo {
list<BSONObj> blah;

shared_ptr<Cursor> cursor = NamespaceDetailsTransient::getCursor(ns.c_str() , query);
ClientCursor::CleanupPointer ccPointer;
ClientCursor::Holder ccPointer;
ccPointer.reset( new ClientCursor( QueryOption_NoCursorTimeout, cursor, ns ) );

while ( cursor->ok() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/oplog.h
Expand Up @@ -116,7 +116,7 @@ namespace mongo {
FindingStartMode _findingStartMode;
auto_ptr< CoveredIndexMatcher > _matcher;
Timer _findingStartTimer;
ClientCursor::CleanupPointer _findingStartCursor;
ClientCursor::Holder _findingStartCursor;
shared_ptr<Cursor> _c;
ClientCursor::YieldData _yieldData;
DiskLoc extentFirstLoc( const DiskLoc &rec );
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/ops/count.cpp
Expand Up @@ -53,7 +53,7 @@ namespace mongo {
shared_ptr<Cursor> cursor =
NamespaceDetailsTransient::getCursor( ns, query, BSONObj(), QueryPlanSelectionPolicy::any(),
&simpleEqualityMatch );
ClientCursor::CleanupPointer ccPointer;
ClientCursor::Holder ccPointer;
ElapsedTracker timeToStartYielding( 256, 20 );
try {
while( cursor->ok() ) {
Expand Down
4 changes: 2 additions & 2 deletions src/mongo/db/ops/query.cpp
Expand Up @@ -81,7 +81,7 @@ namespace mongo {

QueryResult* processGetMore(const char *ns, int ntoreturn, long long cursorid , CurOp& curop, int pass, bool& exhaust ) {
exhaust = false;
ClientCursor::Pointer p(cursorid);
ClientCursor::Pin p(cursorid);
ClientCursor *cc = p.c();

int bufSize = 512 + sizeof( QueryResult ) + MaxBytesToReturnToClientAtOnce;
Expand Down Expand Up @@ -616,7 +616,7 @@ namespace mongo {
bool saveClientCursor = false;
const char *exhaust = 0;
OpTime slaveReadTill;
ClientCursor::CleanupPointer ccPointer;
ClientCursor::Holder ccPointer;
ccPointer.reset( new ClientCursor( QueryOption_NoCursorTimeout, cursor, ns ) );

for( ; cursor->ok(); cursor->advance() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/pipeline/document_source.h
Expand Up @@ -372,7 +372,7 @@ namespace mongo {
/*
In order to yield, we need a ClientCursor.
*/
ClientCursor::CleanupPointer pClientCursor;
ClientCursor::Holder pClientCursor;

/*
Advance the cursor, and yield sometimes.
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/queryoptimizercursorimpl.cpp
Expand Up @@ -279,7 +279,7 @@ namespace mongo {
bool _mustAdvance;
bool _capped;
shared_ptr<Cursor> _c;
ClientCursor::CleanupPointer _cc;
ClientCursor::Holder _cc;
DiskLoc _posBeforeYield;
ClientCursor::YieldData _yieldData;
const QueryPlanSelectionPolicy &_selectionPolicy;
Expand Down
16 changes: 8 additions & 8 deletions src/mongo/dbtests/queryoptimizercursortests.cpp
Expand Up @@ -2298,7 +2298,7 @@ namespace QueryOptimizerCursorTests {
setQueryOptimizerCursor( BSON( "x" << GT << 0 ) );
ASSERT_EQUALS( 1, current().getIntField( "x" ) );

ClientCursor::CleanupPointer p;
ClientCursor::Holder p;
p.reset( new ClientCursor( QueryOption_NoCursorTimeout, c(), ns() ) );
ClientCursor::YieldData yieldData;
p->prepareToYield( yieldData );
Expand All @@ -2323,7 +2323,7 @@ namespace QueryOptimizerCursorTests {
_cli.insert( ns(), BSON( "_id" << i << "x" << i ) );
}

ClientCursor::CleanupPointer p;
ClientCursor::Holder p;
ClientCursor::YieldData yieldData;
{
Lock::GlobalWrite lk;
Expand Down Expand Up @@ -2364,7 +2364,7 @@ namespace QueryOptimizerCursorTests {
Lock::GlobalWrite lk;

Client::Context ctx( ns() );
ClientCursor::CleanupPointer p;
ClientCursor::Holder p;
p.reset
( new ClientCursor
( QueryOption_NoCursorTimeout,
Expand All @@ -2385,7 +2385,7 @@ namespace QueryOptimizerCursorTests {
_cli.insert( ns(), BSON( "a" << 1 << "b" << 1 ) );
Lock::GlobalWrite lk;
Client::Context ctx( ns() );
ClientCursor::CleanupPointer p;
ClientCursor::Holder p;
p.reset
( new ClientCursor
( 0,
Expand Down Expand Up @@ -2413,7 +2413,7 @@ namespace QueryOptimizerCursorTests {
Lock::GlobalWrite lk;

Client::Context ctx( ns() );
ClientCursor::CleanupPointer p;
ClientCursor::Holder p;
p.reset
( new ClientCursor
( 0,
Expand Down Expand Up @@ -2450,7 +2450,7 @@ namespace QueryOptimizerCursorTests {
Lock::GlobalWrite lk;

Client::Context ctx( ns() );
ClientCursor::CleanupPointer p;
ClientCursor::Holder p;
p.reset
( new ClientCursor
( QueryOption_NoCursorTimeout,
Expand Down Expand Up @@ -2512,7 +2512,7 @@ namespace QueryOptimizerCursorTests {
Lock::GlobalWrite lk;

Client::Context ctx( ns() );
ClientCursor::CleanupPointer p;
ClientCursor::Holder p;
p.reset
( new ClientCursor
( QueryOption_NoCursorTimeout,
Expand Down Expand Up @@ -2561,7 +2561,7 @@ namespace QueryOptimizerCursorTests {
{
Lock::DBWrite lk(ns());
Client::Context ctx( ns() );
ClientCursor::CleanupPointer p;
ClientCursor::Holder p;
p.reset
( new ClientCursor
( QueryOption_NoCursorTimeout,
Expand Down
8 changes: 4 additions & 4 deletions src/mongo/dbtests/querytests.cpp
Expand Up @@ -210,7 +210,7 @@ namespace QueryTests {
// Check internal server handoff to getmore.
Lock::DBWrite lk(ns);
Client::Context ctx( ns );
ClientCursor::Pointer clientCursor( cursorId );
ClientCursor::Pin clientCursor( cursorId );
ASSERT( clientCursor.c()->pq );
ASSERT_EQUALS( 2, clientCursor.c()->pq->getNumToReturn() );
ASSERT_EQUALS( 2, clientCursor.c()->pos() );
Expand Down Expand Up @@ -458,7 +458,7 @@ namespace QueryTests {
ASSERT_EQUALS( two, c->next()["ts"].Date() );
long long cursorId = c->getCursorId();

ClientCursor::Pointer clientCursor( cursorId );
ClientCursor::Pin clientCursor( cursorId );
ASSERT_EQUALS( three.millis, clientCursor.c()->getSlaveReadTill().asDate() );
}
};
Expand Down Expand Up @@ -1287,7 +1287,7 @@ namespace QueryTests {

ClientCursor *clientCursor = 0;
{
ClientCursor::Pointer clientCursorPointer( cursorId );
ClientCursor::Pin clientCursorPointer( cursorId );
clientCursor = clientCursorPointer.c();
// clientCursorPointer destructor unpins the cursor.
}
Expand Down Expand Up @@ -1324,7 +1324,7 @@ namespace QueryTests {

{
Client::WriteContext ctx( ns() );
ClientCursor::Pointer pinCursor( cursorId );
ClientCursor::Pin pinCursor( cursorId );

ASSERT_THROWS( client().killCursor( cursorId ), MsgAssertionException );
string expectedAssertion =
Expand Down

0 comments on commit e5896ba

Please sign in to comment.