Files
mongo/util/concurrency/vars.cpp

53 lines
1.6 KiB
C++
Raw Normal View History

2010-05-16 18:32:06 -04:00
// vars.cpp
/**
* Copyright (C) 2008 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,b
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "pch.h"
#include "value.h"
2010-05-26 00:46:49 -04:00
#include "mutex.h"
2010-05-16 18:32:06 -04:00
namespace mongo {
2010-05-26 00:46:49 -04:00
mutex _atomicMutex("_atomicMutex");
MutexDebugger mutexDebugger;
2010-06-02 17:15:31 -04:00
MutexDebugger::MutexDebugger() :
x( *(new boost::mutex()) ), magic(0x12345678) {
// optional way to debug lock order
/*
a = "a_lock";
b = "b_lock";
*/
}
2010-05-26 00:46:49 -04:00
void MutexDebugger::programEnding() {
if( followers.size() ) {
2010-05-28 11:32:40 -04:00
std::cout << followers.size() << " mutexes in program" << endl;
2010-05-26 00:46:49 -04:00
for( map< mid, set<mid> >::iterator i = followers.begin(); i != followers.end(); i++ ) {
2010-06-02 16:38:28 -04:00
cout << i->first;
2010-06-02 16:43:05 -04:00
if( maxNest[i->first] > 1 )
cout << " maxNest:" << maxNest[i->first];
2010-06-02 16:38:28 -04:00
cout << '\n';
2010-05-26 00:46:49 -04:00
for( set<mid>::iterator j = i->second.begin(); j != i->second.end(); j++ )
cout << " " << *j << '\n';
}
cout.flush();
}
}
2010-05-16 18:32:06 -04:00
}