main_notify: just use cond_signal to wakeup, no need to trylock
pthread_cond_signal is a no-op if nothing is waiting on it git-svn-id: https://svn.musicpd.org/mpd/trunk@7351 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
78370a9759
commit
ae1335753a
@ -90,22 +90,12 @@ static int wakeup_via_pipe(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wakeup_via_cond(void)
|
|
||||||
{
|
|
||||||
int ret = pthread_mutex_trylock(&main_wakeup_mutex);
|
|
||||||
|
|
||||||
if (ret == EBUSY)
|
|
||||||
return; /* nope, no need to wakeup at all */
|
|
||||||
pthread_cond_signal(&main_wakeup);
|
|
||||||
pthread_mutex_unlock(&main_wakeup_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wakeup_main_task(void)
|
void wakeup_main_task(void)
|
||||||
{
|
{
|
||||||
assert(!pthread_equal(main_task, pthread_self()));
|
assert(!pthread_equal(main_task, pthread_self()));
|
||||||
|
|
||||||
if (!wakeup_via_pipe())
|
if (!wakeup_via_pipe())
|
||||||
wakeup_via_cond();
|
pthread_cond_signal(&main_wakeup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main_notify_lock(void)
|
void main_notify_lock(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user