aboutsummaryrefslogtreecommitdiffstats
path: root/src/event
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-10 09:00:04 +0200
committerMax Kellermann <max@duempel.org>2013-08-10 09:00:04 +0200
commitd23c907a94a58d5e6ad2f42f6eecf358e3d9f775 (patch)
treee399175cc7a39d786e9ee3403c8cec8e1cd785c6 /src/event
parent018f4155eb7b476b96a7b401377be78e00ca7dd2 (diff)
downloadmpd-d23c907a94a58d5e6ad2f42f6eecf358e3d9f775.tar.gz
mpd-d23c907a94a58d5e6ad2f42f6eecf358e3d9f775.tar.xz
mpd-d23c907a94a58d5e6ad2f42f6eecf358e3d9f775.zip
thread/Id: new class replacing GThread pointers
Remove a GLib dependencies from class EventLoop and DatabaseLock.
Diffstat (limited to 'src/event')
-rw-r--r--src/event/Loop.cxx6
-rw-r--r--src/event/Loop.hxx11
2 files changed, 9 insertions, 8 deletions
diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx
index ad20245de..5154c3562 100644
--- a/src/event/Loop.cxx
+++ b/src/event/Loop.cxx
@@ -23,12 +23,12 @@
void
EventLoop::Run()
{
- assert(thread == nullptr);
- thread = g_thread_self();
+ assert(thread.IsNull());
+ thread = ThreadId::GetCurrent();
g_main_loop_run(loop);
- assert(thread == g_thread_self());
+ assert(thread.IsInside());
}
guint
diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx
index 02befe79e..e26da9687 100644
--- a/src/event/Loop.hxx
+++ b/src/event/Loop.hxx
@@ -21,6 +21,7 @@
#define MPD_EVENT_LOOP_HXX
#include "check.h"
+#include "thread/Id.hxx"
#include "gcc.h"
#include <glib.h>
@@ -34,19 +35,19 @@ class EventLoop {
/**
* A reference to the thread that is currently inside Run().
*/
- GThread *thread;
+ ThreadId thread;
public:
EventLoop()
:context(g_main_context_new()),
loop(g_main_loop_new(context, false)),
- thread(nullptr) {}
+ thread(ThreadId::Null()) {}
struct Default {};
EventLoop(gcc_unused Default _dummy)
:context(g_main_context_ref(g_main_context_default())),
loop(g_main_loop_new(context, false)),
- thread(nullptr) {}
+ thread(ThreadId::Null()) {}
~EventLoop() {
g_main_loop_unref(loop);
@@ -58,9 +59,9 @@ public:
*/
gcc_pure
bool IsInside() const {
- assert(thread != nullptr);
+ assert(!thread.IsNull());
- return g_thread_self() == thread;
+ return thread.IsInside();
}
GMainContext *GetContext() {