diff options
author | Max Kellermann <max@duempel.org> | 2013-08-07 22:42:45 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-08 23:04:07 +0200 |
commit | 018f4155eb7b476b96a7b401377be78e00ca7dd2 (patch) | |
tree | fb7b46b83a8850e426a2c80f3734d14547843afe /src/IOThread.cxx | |
parent | 9ab0a1f5f16b475199540349905e4d79001b8cec (diff) | |
download | mpd-018f4155eb7b476b96a7b401377be78e00ca7dd2.tar.gz mpd-018f4155eb7b476b96a7b401377be78e00ca7dd2.tar.xz mpd-018f4155eb7b476b96a7b401377be78e00ca7dd2.zip |
event: add function BlockingCall()
Replaces io_thread_call(). This approach is more generic and easier
to use due to std::function.
Diffstat (limited to '')
-rw-r--r-- | src/IOThread.cxx | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/IOThread.cxx b/src/IOThread.cxx index ef0cec4d6..cba9c9263 100644 --- a/src/IOThread.cxx +++ b/src/IOThread.cxx @@ -115,53 +115,3 @@ io_thread_inside(void) { return io.thread != NULL && g_thread_self() == io.thread; } - -struct call_data { - GThreadFunc function; - gpointer data; - bool done; - gpointer result; -}; - -static gboolean -io_thread_call_func(gpointer _data) -{ - struct call_data *data = (struct call_data *)_data; - - gpointer result = data->function(data->data); - - io.mutex.lock(); - data->done = true; - data->result = result; - io.cond.broadcast(); - io.mutex.unlock(); - - return false; -} - -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, - _data, - false, - nullptr, - }; - - io.loop->AddIdle(io_thread_call_func, &data); - - io.mutex.lock(); - while (!data.done) - io.cond.wait(io.mutex); - io.mutex.unlock(); - - return data.result; -} |