From 46bab7e4b921b79924643bacd08dcd3d1404ceb6 Mon Sep 17 00:00:00 2001 From: Denis Krjuchkov Date: Wed, 27 Nov 2013 17:04:38 +0600 Subject: Add infrastructure for using multiple event loops This change adds two configuration options: --with-eventloop=[glib|internal|auto] --with-pollmethod=[epoll|auto] First allows switching between GLib event loop and internal one. Second chooses backend to use for internal event loop. Conditional compilation symbols are changed accordingly. Additional helper macro MPD_OPTIONAL_FUNC_NODEF is added as well. --- src/event/Call.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/event/Call.cxx') diff --git a/src/event/Call.cxx b/src/event/Call.cxx index ab1d5ffbd..7767824f9 100644 --- a/src/event/Call.cxx +++ b/src/event/Call.cxx @@ -28,7 +28,7 @@ #include class BlockingCallMonitor final -#ifndef USE_EPOLL +#ifdef USE_GLIB_EVENTLOOP : DeferredMonitor #endif { @@ -40,20 +40,22 @@ class BlockingCallMonitor final bool done; public: -#ifdef USE_EPOLL +#ifdef USE_INTERNAL_EVENTLOOP BlockingCallMonitor(EventLoop &loop, std::function &&_f) :f(std::move(_f)), done(false) { loop.AddCall([this](){ this->DoRun(); }); } -#else +#endif + +#ifdef USE_GLIB_EVENTLOOP BlockingCallMonitor(EventLoop &_loop, std::function &&_f) :DeferredMonitor(_loop), f(std::move(_f)), done(false) {} #endif void Run() { -#ifndef USE_EPOLL +#ifdef USE_GLIB_EVENTLOOP assert(!done); Schedule(); @@ -65,13 +67,14 @@ public: mutex.unlock(); } -#ifndef USE_EPOLL +#ifdef USE_GLIB_EVENTLOOP private: virtual void RunDeferred() override { DoRun(); } +#endif -#else +#ifdef USE_INTERNAL_EVENTLOOP public: #endif void DoRun() { -- cgit v1.2.3