diff options
author | Max Kellermann <max@duempel.org> | 2011-08-31 07:33:02 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-08-31 07:33:07 +0200 |
commit | f3ac8a7cd91f368cef7c6cf2387680e99212356d (patch) | |
tree | 0d86d8546ed8f142333233ded4d997177bf7e175 /src/io_thread.c | |
parent | f3d95f70e230590d918098c396fb0901cee4b8c3 (diff) | |
download | mpd-f3ac8a7cd91f368cef7c6cf2387680e99212356d.tar.gz mpd-f3ac8a7cd91f368cef7c6cf2387680e99212356d.tar.xz mpd-f3ac8a7cd91f368cef7c6cf2387680e99212356d.zip |
io_thread: allow _call() from inside the thread
Diffstat (limited to 'src/io_thread.c')
-rw-r--r-- | src/io_thread.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/io_thread.c b/src/io_thread.c index a0e3a8844..fa6dee337 100644 --- a/src/io_thread.c +++ b/src/io_thread.c @@ -107,6 +107,12 @@ io_thread_context(void) return io.context; } +bool +io_thread_inside(void) +{ + return io.thread != NULL && g_thread_self() == io.thread; +} + guint io_thread_idle_add(GSourceFunc function, gpointer data) { @@ -154,6 +160,13 @@ io_thread_call_func(gpointer _data) gpointer io_thread_call(GThreadFunc function, gpointer _data) { + assert(io.thread != NULL); + + if (io_thread_inside()) + /* we're already in the I/O thread - no + synchronization needed */ + return function(_data); + struct call_data data = { .function = function, .data = _data, |