diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ClientMessage.cxx | 1 | ||||
-rw-r--r-- | src/Idle.cxx | 34 | ||||
-rw-r--r-- | src/Idle.hxx | 12 | ||||
-rw-r--r-- | src/Main.cxx | 2 |
4 files changed, 5 insertions, 44 deletions
diff --git a/src/ClientMessage.cxx b/src/ClientMessage.cxx index 6fbcf3371..619964b3c 100644 --- a/src/ClientMessage.cxx +++ b/src/ClientMessage.cxx @@ -19,7 +19,6 @@ #include "ClientMessage.hxx" -#include <assert.h> #include <glib.h> G_GNUC_PURE diff --git a/src/Idle.cxx b/src/Idle.cxx index fce0cb7da..f1423ebeb 100644 --- a/src/Idle.cxx +++ b/src/Idle.cxx @@ -26,11 +26,11 @@ #include "Idle.hxx" #include "GlobalEvents.hxx" +#include <atomic> + #include <assert.h> -#include <glib.h> -static unsigned idle_flags; -static GMutex *idle_mutex = NULL; +static std::atomic_uint idle_flags; static const char *const idle_names[] = { "database", @@ -44,32 +44,15 @@ static const char *const idle_names[] = { "update", "subscription", "message", - NULL + nullptr }; 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); - g_mutex_lock(idle_mutex); idle_flags |= flags; - g_mutex_unlock(idle_mutex); GlobalEvents::Emit(GlobalEvents::IDLE); } @@ -77,14 +60,7 @@ idle_add(unsigned flags) unsigned idle_get(void) { - unsigned flags; - - g_mutex_lock(idle_mutex); - flags = idle_flags; - idle_flags = 0; - g_mutex_unlock(idle_mutex); - - return flags; + return idle_flags.fetch_and(0); } const char*const* diff --git a/src/Idle.hxx b/src/Idle.hxx index e77061300..6e4fbf787 100644 --- a/src/Idle.hxx +++ b/src/Idle.hxx @@ -62,18 +62,6 @@ enum { }; /** - * Initialize the mutex - */ -void -idle_init(void); - -/** - * Destroy the mutex - */ -void -idle_deinit(void); - -/** * Adds idle flag (with bitwise "or") and queues notifications to all * clients. */ diff --git a/src/Main.cxx b/src/Main.cxx index a07e8fefa..6ccede6f1 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -375,7 +375,6 @@ int mpd_main(int argc, char *argv[]) io_thread_init(); winsock_init(); - idle_init(); config_global_init(); success = parse_cmdline(argc, argv, &options, &error); @@ -565,7 +564,6 @@ int mpd_main(int argc, char *argv[]) archive_plugin_deinit_all(); #endif config_global_finish(); - idle_deinit(); stats_global_finish(); io_thread_deinit(); daemonize_finish(); |