aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/SocketMonitor.cxx
diff options
context:
space:
mode:
authorDenis Krjuchkov <denis@crazydev.net>2013-11-27 17:04:38 +0600
committerDenis Krjuchkov <denis@crazydev.net>2013-11-27 17:28:36 +0600
commit46bab7e4b921b79924643bacd08dcd3d1404ceb6 (patch)
tree2fe8e1b2185dba89d953b5d02f22cc0781e17c2c /src/event/SocketMonitor.cxx
parent22fb49fa90241abfaf5ac81de462f4b2c274f7d0 (diff)
downloadmpd-46bab7e4b921b79924643bacd08dcd3d1404ceb6.tar.gz
mpd-46bab7e4b921b79924643bacd08dcd3d1404ceb6.tar.xz
mpd-46bab7e4b921b79924643bacd08dcd3d1404ceb6.zip
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.
Diffstat (limited to 'src/event/SocketMonitor.cxx')
-rw-r--r--src/event/SocketMonitor.cxx20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx
index 2b97059f7..fdef0acb6 100644
--- a/src/event/SocketMonitor.cxx
+++ b/src/event/SocketMonitor.cxx
@@ -32,7 +32,7 @@
#include <sys/socket.h>
#endif
-#ifdef USE_EPOLL
+#ifdef USE_INTERNAL_EVENTLOOP
void
SocketMonitor::Dispatch(unsigned flags)
@@ -43,7 +43,9 @@ SocketMonitor::Dispatch(unsigned flags)
Cancel();
}
-#else
+#endif
+
+#ifdef USE_GLIB_EVENTLOOP
/*
* GSource methods
@@ -113,14 +115,14 @@ void
SocketMonitor::Open(int _fd)
{
assert(fd < 0);
-#ifndef USE_EPOLL
+#ifdef USE_GLIB_EVENTLOOP
assert(source == nullptr);
#endif
assert(_fd >= 0);
fd = _fd;
-#ifndef USE_EPOLL
+#ifdef USE_GLIB_EVENTLOOP
poll = {fd, 0, 0};
source = (Source *)g_source_new(&socket_monitor_source_funcs,
@@ -142,7 +144,7 @@ SocketMonitor::Steal()
int result = fd;
fd = -1;
-#ifndef USE_EPOLL
+#ifdef USE_GLIB_EVENTLOOP
g_source_destroy(&source->base);
g_source_unref(&source->base);
source = nullptr;
@@ -156,7 +158,7 @@ SocketMonitor::Abandon()
{
assert(IsDefined());
-#ifdef USE_EPOLL
+#ifdef USE_INTERNAL_EVENTLOOP
fd = -1;
loop.Abandon(*this);
#else
@@ -178,7 +180,7 @@ SocketMonitor::Schedule(unsigned flags)
if (flags == GetScheduledFlags())
return;
-#ifdef USE_EPOLL
+#ifdef USE_INTERNAL_EVENTLOOP
if (scheduled_flags == 0)
loop.AddFD(fd, flags, *this);
else if (flags == 0)
@@ -187,7 +189,9 @@ SocketMonitor::Schedule(unsigned flags)
loop.ModifyFD(fd, flags, *this);
scheduled_flags = flags;
-#else
+#endif
+
+#ifdef USE_GLIB_EVENTLOOP
poll.events = flags;
poll.revents &= flags;