mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-695 expose boost object to work better with older boost versions
This commit is contained in:
parent
c971842a55
commit
c457973dc6
@ -91,7 +91,7 @@ namespace mongo {
|
||||
pendingUpdated_.notify_all();
|
||||
while( inProgress( name ) ) {
|
||||
checkFailure();
|
||||
pendingUpdated_.wait( lk );
|
||||
pendingUpdated_.wait( lk.boost() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -102,7 +102,7 @@ namespace mongo {
|
||||
return;
|
||||
scoped_lock lk( pendingMutex_ );
|
||||
while( pending_.size() != 0 )
|
||||
pendingUpdated_.wait( lk );
|
||||
pendingUpdated_.wait( lk.boost() );
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ namespace mongo {
|
||||
{
|
||||
scoped_lock lk( a_.pendingMutex_ );
|
||||
if ( a_.pending_.size() == 0 )
|
||||
a_.pendingUpdated_.wait( lk );
|
||||
a_.pendingUpdated_.wait( lk.boost() );
|
||||
}
|
||||
while( 1 ) {
|
||||
string name;
|
||||
|
@ -281,20 +281,26 @@ namespace mongo {
|
||||
~StaticObserver() { __destroyingStatics = true; }
|
||||
};
|
||||
|
||||
// On pthread systems, it is an error to destroy a mutex while held. Static global
|
||||
// mutexes may be held upon shutdown in our implementation, and this way we avoid
|
||||
// destroying them.
|
||||
class mutex : boost::noncopyable {
|
||||
public:
|
||||
mutex() { new (_buf) boost::mutex(); }
|
||||
~mutex() {
|
||||
if( !__destroyingStatics ) {
|
||||
me().boost::mutex::~mutex();
|
||||
boost().boost::mutex::~mutex();
|
||||
}
|
||||
}
|
||||
void lock() { me().lock(); }
|
||||
void unlock() { me().unlock(); }
|
||||
bool try_lock() { return me().try_lock(); }
|
||||
typedef boost::unique_lock<mongo::mutex> scoped_lock;
|
||||
class scoped_lock : boost::noncopyable {
|
||||
public:
|
||||
scoped_lock( mongo::mutex &m ) : _l( m.boost() ) {}
|
||||
boost::mutex::scoped_lock &boost() { return _l; }
|
||||
private:
|
||||
boost::mutex::scoped_lock _l;
|
||||
};
|
||||
private:
|
||||
boost::mutex &me() { return *( boost::mutex * )( _buf ); }
|
||||
boost::mutex &boost() { return *( boost::mutex * )( _buf ); }
|
||||
char _buf[ sizeof( boost::mutex ) ];
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace mongo {
|
||||
|
||||
scoped_lock l( _lock );
|
||||
while( _queue.empty() )
|
||||
_condition.wait( l );
|
||||
_condition.wait( l.boost() );
|
||||
|
||||
T t = _queue.front();
|
||||
_queue.pop();
|
||||
|
@ -101,7 +101,7 @@ ThreadPool::~ThreadPool(){
|
||||
void ThreadPool::join(){
|
||||
scoped_lock lock(_mutex);
|
||||
while(_tasksRemaining){
|
||||
_condition.wait(lock);
|
||||
_condition.wait(lock.boost());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user