aboutsummaryrefslogtreecommitdiffstats
path: root/src/idle.c
diff options
context:
space:
mode:
authorThomas Jansen <mithi@mithi.net>2008-12-28 21:02:14 +0100
committerThomas Jansen <mithi@mithi.net>2008-12-28 21:02:14 +0100
commit8332a70406140cbc7594ca9d54cb9a600b470bb4 (patch)
tree29a4266a8cda671bf375027eaef8b94ffe6a0a98 /src/idle.c
parent5e3dc6946f13e721030b887b60e383b58879bc62 (diff)
downloadmpd-8332a70406140cbc7594ca9d54cb9a600b470bb4.tar.gz
mpd-8332a70406140cbc7594ca9d54cb9a600b470bb4.tar.xz
mpd-8332a70406140cbc7594ca9d54cb9a600b470bb4.zip
idle: migrate from pthread to glib threads
Diffstat (limited to '')
-rw-r--r--src/idle.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/idle.c b/src/idle.c
index 884086aae..4de252ada 100644
--- a/src/idle.c
+++ b/src/idle.c
@@ -25,10 +25,10 @@
#include "main_notify.h"
#include <assert.h>
-#include <pthread.h>
+#include <glib.h>
static unsigned idle_flags;
-static pthread_mutex_t idle_mutex = PTHREAD_MUTEX_INITIALIZER;
+static GMutex *idle_mutex = NULL;
static const char *const idle_names[] = {
"database",
@@ -43,13 +43,28 @@ static const char *const idle_names[] = {
};
void
+idle_init(void)
+{
+ g_assert(idle_mutex == NULL);
+ idle_mutex = g_mutex_new();
+}
+
+void
+idle_deinit(void)
+{
+ g_assert(idle_mutex != NULL);
+ g_mutex_free(idle_mutex);
+ idle_mutex = NULL;
+}
+
+void
idle_add(unsigned flags)
{
assert(flags != 0);
- pthread_mutex_lock(&idle_mutex);
+ g_mutex_lock(idle_mutex);
idle_flags |= flags;
- pthread_mutex_unlock(&idle_mutex);
+ g_mutex_unlock(idle_mutex);
wakeup_main_task();
}
@@ -59,10 +74,10 @@ idle_get(void)
{
unsigned flags;
- pthread_mutex_lock(&idle_mutex);
+ g_mutex_lock(idle_mutex);
flags = idle_flags;
idle_flags = 0;
- pthread_mutex_unlock(&idle_mutex);
+ g_mutex_unlock(idle_mutex);
return flags;
}