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.
This commit is contained in:
@@ -24,9 +24,10 @@
|
||||
void
|
||||
DeferredMonitor::Cancel()
|
||||
{
|
||||
#ifdef USE_EPOLL
|
||||
#ifdef USE_INTERNAL_EVENTLOOP
|
||||
pending = false;
|
||||
#else
|
||||
#endif
|
||||
#ifdef USE_GLIB_EVENTLOOP
|
||||
const auto id = source_id.exchange(0);
|
||||
if (id != 0)
|
||||
g_source_remove(id);
|
||||
@@ -36,10 +37,11 @@ DeferredMonitor::Cancel()
|
||||
void
|
||||
DeferredMonitor::Schedule()
|
||||
{
|
||||
#ifdef USE_EPOLL
|
||||
#ifdef USE_INTERNAL_EVENTLOOP
|
||||
if (!pending.exchange(true))
|
||||
fd.Write();
|
||||
#else
|
||||
#endif
|
||||
#ifdef USE_GLIB_EVENTLOOP
|
||||
const unsigned id = loop.AddIdle(Callback, this);
|
||||
const auto old_id = source_id.exchange(id);
|
||||
if (old_id != 0)
|
||||
@@ -47,7 +49,7 @@ DeferredMonitor::Schedule()
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_EPOLL
|
||||
#ifdef USE_INTERNAL_EVENTLOOP
|
||||
|
||||
bool
|
||||
DeferredMonitor::OnSocketReady(unsigned)
|
||||
@@ -60,7 +62,9 @@ DeferredMonitor::OnSocketReady(unsigned)
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif
|
||||
|
||||
#ifdef USE_GLIB_EVENTLOOP
|
||||
|
||||
void
|
||||
DeferredMonitor::Run()
|
||||
|
||||
Reference in New Issue
Block a user