0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
This commit is contained in:
Eliot Horowitz 2011-01-05 00:32:30 -05:00
parent 4b80354d2f
commit 19f1a2c184
6 changed files with 27 additions and 27 deletions

View File

@ -301,7 +301,7 @@ namespace mongo {
int x = i->second;
BSONObjIterator it( currKey() );
while ( x && it.more() ){
while ( x && it.more() ) {
it.next();
x--;
}

View File

@ -96,7 +96,7 @@ namespace mongo {
DEV { // ensure there are no overlaps
// this can be very slow - n^2 - so make it RARELY
RARELY {
RARELY {
for (iterator it(_writes.begin()), end(boost::prior(_writes.end())); it != end; ++it) {
assert(!it->overlaps(*boost::next(it)));
}

View File

@ -170,7 +170,7 @@ namespace mongo {
const bool _doDurOps;
};
static string fileName(const char* dbName, int fileNo){
static string fileName(const char* dbName, int fileNo) {
stringstream ss;
ss << dbName << '.';
assert( fileNo >= 0 );
@ -197,10 +197,10 @@ namespace mongo {
void RecoveryJob::_close() {
MongoFile::flushAll(true);
_mmfs.clear();
_mmfs.clear();
}
void RecoveryJob::write(const ParsedJournalEntry& entry){
void RecoveryJob::write(const ParsedJournalEntry& entry) {
const string fn = fileName(entry.dbName, entry.e->getFileNo());
MongoFile* file;
{
@ -209,7 +209,7 @@ namespace mongo {
}
MongoMMF* mmf;
if (file){
if (file) {
assert(file->isMongoMMF());
mmf = (MongoMMF*)file;
}

View File

@ -109,12 +109,12 @@ namespace mongo {
PointerToMMF();
/** register view. \
threadsafe
threadsafe
*/
void add(void *view, MongoMMF *f);
/** de-register view.
threadsafe
/** de-register view.
threadsafe
*/
void remove(void *view);

View File

@ -57,64 +57,64 @@ namespace ThreadedTests {
}
};
class MongoMutexTest : public ThreadedTest<135> {
class MongoMutexTest : public ThreadedTest<135> {
enum { N = 100000 };
MongoMutex *mm;
virtual void setup() {
virtual void setup() {
mm = new MongoMutex("MongoMutexTest");
}
virtual void subthread() {
virtual void subthread() {
Client::initThread("mongomutextest");
sleepmillis(0);
for( int i = 0; i < N; i++ ) {
if( i % 20000 == 0 )
for( int i = 0; i < N; i++ ) {
if( i % 20000 == 0 )
log() << i << endl;
if( i % 7 == 0 ) {
if( i % 7 == 0 ) {
mm->lock_shared();
mm->lock_shared();
mm->unlock_shared();
mm->unlock_shared();
}
else if( i % 7 == 1 ) {
else if( i % 7 == 1 ) {
mm->lock_shared();
ASSERT( mm->atLeastReadLocked() );
mm->unlock_shared();
}
else if( i % 7 == 2 ) {
else if( i % 7 == 2 ) {
mm->lock();
ASSERT( mm->isWriteLocked() );
mm->unlock();
}
else if( i % 7 == 3 ) {
else if( i % 7 == 3 ) {
mm->lock();
mm->lock_shared();
ASSERT( mm->isWriteLocked() );
mm->unlock_shared();
mm->unlock();
}
else if( i % 7 == 4 ) {
else if( i % 7 == 4 ) {
mm->lock();
mm->releaseEarly();
mm->unlock();
}
else if( i % 7 == 5 ) {
if( mm->lock_try(1) ) {
else if( i % 7 == 5 ) {
if( mm->lock_try(1) ) {
mm->unlock();
}
}
else if( i % 7 == 6 ) {
if( mm->lock_shared_try(0) ) {
else if( i % 7 == 6 ) {
if( mm->lock_shared_try(0) ) {
mm->unlock_shared();
}
}
else {
else {
mm->lock_shared();
mm->unlock_shared();
}
}
cc().shutdown();
}
virtual void validate() {
virtual void validate() {
ASSERT( !mm->atLeastReadLocked() );
mm->lock();
mm->unlock();

View File

@ -57,7 +57,7 @@ namespace mongo {
while( 1 ) {
if( TryAcquireSRWLockShared(&_lock) )
return true;
if( curTimeMicros64() >= end )
if( curTimeMicros64() >= end )
break;
Sleep(1);
}
@ -68,7 +68,7 @@ namespace mongo {
while( 1 ) {
if( TryAcquireSRWLockExclusive(&_lock) )
return true;
if( curTimeMicros64() >= end )
if( curTimeMicros64() >= end )
break;
Sleep(1);
}