mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
pipeline: don't require holding lock for ConditionVar.notify()
As far as I know, none of the implementations strictly require this, and this may cause the waiting thread to wake up only for it to immediately have to wait for the lock again. This change brings our implementation closer to C++11 std::condition_variable semantics.
This commit is contained in:
parent
36dd8889e7
commit
c4f52bfdfe
@ -165,9 +165,9 @@ void ConditionVarDebug::
|
|||||||
notify() {
|
notify() {
|
||||||
_mutex._global_lock->lock();
|
_mutex._global_lock->lock();
|
||||||
|
|
||||||
Thread *current_thread = Thread::get_current_thread();
|
/*
|
||||||
|
|
||||||
if (!_mutex.do_debug_is_locked()) {
|
if (!_mutex.do_debug_is_locked()) {
|
||||||
|
Thread *current_thread = Thread::get_current_thread();
|
||||||
ostringstream ostr;
|
ostringstream ostr;
|
||||||
ostr << *current_thread << " attempted to notify "
|
ostr << *current_thread << " attempted to notify "
|
||||||
<< *this << " without holding " << _mutex;
|
<< *this << " without holding " << _mutex;
|
||||||
@ -175,8 +175,10 @@ notify() {
|
|||||||
_mutex._global_lock->unlock();
|
_mutex._global_lock->unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (thread_cat->is_spam()) {
|
if (thread_cat->is_spam()) {
|
||||||
|
Thread *current_thread = Thread::get_current_thread();
|
||||||
thread_cat.spam()
|
thread_cat.spam()
|
||||||
<< *current_thread << " notifying " << *this << "\n";
|
<< *current_thread << " notifying " << *this << "\n";
|
||||||
}
|
}
|
||||||
|
@ -165,9 +165,9 @@ void ConditionVarFullDebug::
|
|||||||
notify() {
|
notify() {
|
||||||
_mutex._global_lock->lock();
|
_mutex._global_lock->lock();
|
||||||
|
|
||||||
Thread *current_thread = Thread::get_current_thread();
|
/*
|
||||||
|
|
||||||
if (!_mutex.do_debug_is_locked()) {
|
if (!_mutex.do_debug_is_locked()) {
|
||||||
|
Thread *current_thread = Thread::get_current_thread();
|
||||||
ostringstream ostr;
|
ostringstream ostr;
|
||||||
ostr << *current_thread << " attempted to notify "
|
ostr << *current_thread << " attempted to notify "
|
||||||
<< *this << " without holding " << _mutex;
|
<< *this << " without holding " << _mutex;
|
||||||
@ -175,8 +175,10 @@ notify() {
|
|||||||
_mutex._global_lock->unlock();
|
_mutex._global_lock->unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (thread_cat->is_spam()) {
|
if (thread_cat->is_spam()) {
|
||||||
|
Thread *current_thread = Thread::get_current_thread();
|
||||||
thread_cat.spam()
|
thread_cat.spam()
|
||||||
<< *current_thread << " notifying " << *this << "\n";
|
<< *current_thread << " notifying " << *this << "\n";
|
||||||
}
|
}
|
||||||
@ -198,9 +200,9 @@ void ConditionVarFullDebug::
|
|||||||
notify_all() {
|
notify_all() {
|
||||||
_mutex._global_lock->lock();
|
_mutex._global_lock->lock();
|
||||||
|
|
||||||
Thread *current_thread = Thread::get_current_thread();
|
/*
|
||||||
|
|
||||||
if (!_mutex.do_debug_is_locked()) {
|
if (!_mutex.do_debug_is_locked()) {
|
||||||
|
Thread *current_thread = Thread::get_current_thread();
|
||||||
ostringstream ostr;
|
ostringstream ostr;
|
||||||
ostr << *current_thread << " attempted to notify "
|
ostr << *current_thread << " attempted to notify "
|
||||||
<< *this << " without holding " << _mutex;
|
<< *this << " without holding " << _mutex;
|
||||||
@ -208,8 +210,10 @@ notify_all() {
|
|||||||
_mutex._global_lock->unlock();
|
_mutex._global_lock->unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (thread_cat->is_spam()) {
|
if (thread_cat->is_spam()) {
|
||||||
|
Thread *current_thread = Thread::get_current_thread();
|
||||||
thread_cat.spam()
|
thread_cat.spam()
|
||||||
<< *current_thread << " notifying all " << *this << "\n";
|
<< *current_thread << " notifying all " << *this << "\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user