Removed debug output
This commit is contained in:
parent
6dec27253c
commit
d9410488a7
@ -33,23 +33,18 @@ namespace cpputils {
|
|||||||
|
|
||||||
template<class LockName>
|
template<class LockName>
|
||||||
inline void LockPool<LockName>::lock(const LockName &lock, std::unique_lock<std::mutex> *lockToFreeWhileWaiting) {
|
inline void LockPool<LockName>::lock(const LockName &lock, std::unique_lock<std::mutex> *lockToFreeWhileWaiting) {
|
||||||
std::cerr << "Aquiring lock " << lock.ToString() << std::endl;
|
|
||||||
std::unique_lock<std::mutex> mutexLock(_mutex); // TODO Is shared_lock enough here?
|
std::unique_lock<std::mutex> mutexLock(_mutex); // TODO Is shared_lock enough here?
|
||||||
std::cerr << (void*)this << " Bquiring lock " << lock.ToString() << std::endl;
|
|
||||||
if (_isLocked(lock)) {
|
if (_isLocked(lock)) {
|
||||||
std::cerr << " is locked " << lock.ToString() << std::endl;
|
|
||||||
if(lockToFreeWhileWaiting != nullptr) {
|
if(lockToFreeWhileWaiting != nullptr) {
|
||||||
lockToFreeWhileWaiting->unlock();
|
lockToFreeWhileWaiting->unlock();
|
||||||
}
|
}
|
||||||
_cv.wait(mutexLock, [this, &lock]{
|
_cv.wait(mutexLock, [this, &lock]{
|
||||||
return !_isLocked(lock);
|
return !_isLocked(lock);
|
||||||
});
|
});
|
||||||
std::cerr << " reaquiring " << lock.ToString() << std::endl;
|
|
||||||
if(lockToFreeWhileWaiting != nullptr) {
|
if(lockToFreeWhileWaiting != nullptr) {
|
||||||
lockToFreeWhileWaiting->lock();
|
lockToFreeWhileWaiting->lock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cerr << "Lock acquired " << lock.ToString() << std::endl;
|
|
||||||
_lockedLocks.push_back(lock);
|
_lockedLocks.push_back(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +55,11 @@ namespace cpputils {
|
|||||||
|
|
||||||
template<class LockName>
|
template<class LockName>
|
||||||
inline void LockPool<LockName>::release(const LockName &lock) {
|
inline void LockPool<LockName>::release(const LockName &lock) {
|
||||||
std::cerr << "Releasing lock "<<lock.ToString()<<std::endl;
|
|
||||||
std::unique_lock<std::mutex> mutexLock(_mutex);
|
std::unique_lock<std::mutex> mutexLock(_mutex);
|
||||||
auto found = std::find(_lockedLocks.begin(), _lockedLocks.end(), lock);
|
auto found = std::find(_lockedLocks.begin(), _lockedLocks.end(), lock);
|
||||||
ASSERT(found != _lockedLocks.end(), "Lock given to release() was not locked");
|
ASSERT(found != _lockedLocks.end(), "Lock given to release() was not locked");
|
||||||
_lockedLocks.erase(found);
|
_lockedLocks.erase(found);
|
||||||
_cv.notify_all();
|
_cv.notify_all();
|
||||||
std::cerr << "Lock released "<<lock.ToString()<<std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user