aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:05 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:05 +0200
commit8814c0c898162f25ef4851df5cf8c9e68ff83942 (patch)
tree2ba39ee9519c6c7f46a86129fda0178528d632b0 /src
parent4f80f53c2998fdafb1311942fc473e63709ac8cd (diff)
downloadmpd-8814c0c898162f25ef4851df5cf8c9e68ff83942.tar.gz
mpd-8814c0c898162f25ef4851df5cf8c9e68ff83942.tar.xz
mpd-8814c0c898162f25ef4851df5cf8c9e68ff83942.zip
use the notify library in main_notify.c
Avoid some duplicated code in main_notify.c.
Diffstat (limited to 'src')
-rw-r--r--src/main_notify.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/main_notify.c b/src/main_notify.c
index 978a401ad..6a14a9871 100644
--- a/src/main_notify.c
+++ b/src/main_notify.c
@@ -28,9 +28,7 @@
static struct ioOps main_notify_IO;
static int main_pipe[2];
static pthread_t main_task;
-static pthread_cond_t main_wakeup = PTHREAD_COND_INITIALIZER;
-static pthread_mutex_t main_wakeup_mutex = PTHREAD_MUTEX_INITIALIZER;
-static volatile int pending;
+static Notify main_notify;
static pthread_mutex_t select_mutex = PTHREAD_MUTEX_INITIALIZER;
static int ioops_fdset(fd_set * rfds,
@@ -74,6 +72,7 @@ void init_main_notify(void)
main_notify_IO.consume = ioops_consume;
registerIO(&main_notify_IO);
main_task = pthread_self();
+ notify_init(&main_notify);
}
static int wakeup_via_pipe(void)
@@ -95,10 +94,10 @@ void wakeup_main_task(void)
{
assert(!pthread_equal(main_task, pthread_self()));
- pending = 1;
+ main_notify.pending = 1;
if (!wakeup_via_pipe())
- pthread_cond_signal(&main_wakeup);
+ notify_signal(&main_notify);
}
void main_notify_lock(void)
@@ -117,10 +116,8 @@ void wait_main_task(void)
{
assert(pthread_equal(main_task, pthread_self()));
- pthread_mutex_lock(&main_wakeup_mutex);
- if (!pending)
- pthread_cond_wait(&main_wakeup, &main_wakeup_mutex);
- pending = 0;
- pthread_mutex_unlock(&main_wakeup_mutex);
+ notify_enter(&main_notify);
+ notify_wait(&main_notify);
+ notify_leave(&main_notify);
}