From 3928c4e9aebf08336192d57175c603a7dc17d8a2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 21 Jan 2013 10:42:47 +0100 Subject: UpdateRemove: Mutex/Cond instead of GMutex/GCond --- src/UpdateRemove.cxx | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/UpdateRemove.cxx') diff --git a/src/UpdateRemove.cxx b/src/UpdateRemove.cxx index f7e6c80ec..acf8bf46c 100644 --- a/src/UpdateRemove.cxx +++ b/src/UpdateRemove.cxx @@ -22,6 +22,8 @@ #include "Playlist.hxx" #include "Partition.hxx" #include "GlobalEvents.hxx" +#include "thread/Mutex.hxx" +#include "thread/Cond.hxx" #include "song.h" #include "Main.hxx" @@ -37,8 +39,8 @@ static const struct song *removed_song; -static GMutex *remove_mutex; -static GCond *remove_cond; +static Mutex remove_mutex; +static Cond remove_cond; /** * Safely remove a song from the database. This must be done in the @@ -64,28 +66,18 @@ song_remove_event(void) global_partition->DeleteSong(*removed_song); /* clear "removed_song" and send signal to update thread */ - g_mutex_lock(remove_mutex); + remove_mutex.lock(); removed_song = NULL; - g_cond_signal(remove_cond); - g_mutex_unlock(remove_mutex); + remove_cond.signal(); + remove_mutex.unlock(); } void update_remove_global_init(void) { - remove_mutex = g_mutex_new(); - remove_cond = g_cond_new(); - GlobalEvents::Register(GlobalEvents::DELETE, song_remove_event); } -void -update_remove_global_finish(void) -{ - g_mutex_free(remove_mutex); - g_cond_free(remove_cond); -} - void update_remove_song(const struct song *song) { @@ -95,10 +87,10 @@ update_remove_song(const struct song *song) GlobalEvents::Emit(GlobalEvents::DELETE); - g_mutex_lock(remove_mutex); + remove_mutex.lock(); while (removed_song != NULL) - g_cond_wait(remove_cond, remove_mutex); + remove_cond.wait(remove_mutex); - g_mutex_unlock(remove_mutex); + remove_mutex.unlock(); } -- cgit v1.2.3