diff options
author | Max Kellermann <max@duempel.org> | 2013-08-07 22:16:59 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-10 13:54:23 +0200 |
commit | c1f4f1fdb64d97b5c3461723a8482ca64efea30e (patch) | |
tree | 54c8a9c1466beec0dbfac1c0b5f5773060c1aa2b /src/event/MultiSocketMonitor.cxx | |
parent | 342333f72a484e9f394026666c4b20e54dc9b756 (diff) | |
download | mpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.tar.gz mpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.tar.xz mpd-c1f4f1fdb64d97b5c3461723a8482ca64efea30e.zip |
EventLoop: new implementation using epoll
Implement an event loop without GLib.
Diffstat (limited to 'src/event/MultiSocketMonitor.cxx')
-rw-r--r-- | src/event/MultiSocketMonitor.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/event/MultiSocketMonitor.cxx b/src/event/MultiSocketMonitor.cxx index dcc5edb38..2ebad02e5 100644 --- a/src/event/MultiSocketMonitor.cxx +++ b/src/event/MultiSocketMonitor.cxx @@ -25,6 +25,48 @@ #include <assert.h> +#ifdef USE_EPOLL + +MultiSocketMonitor::MultiSocketMonitor(EventLoop &_loop) + :IdleMonitor(_loop), TimeoutMonitor(_loop), ready(false) { +} + +MultiSocketMonitor::~MultiSocketMonitor() +{ + // TODO +} + +void +MultiSocketMonitor::Prepare() +{ + int timeout_ms = PrepareSockets(); + if (timeout_ms >= 0) + TimeoutMonitor::Schedule(timeout_ms); + else + TimeoutMonitor::Cancel(); + +} + +void +MultiSocketMonitor::OnIdle() +{ + if (ready) { + ready = false; + DispatchSockets(); + + /* TODO: don't refresh always; require users to call + InvalidateSockets() */ + refresh = true; + } + + if (refresh) { + refresh = false; + Prepare(); + } +} + +#else + /** * The vtable for our GSource implementation. Unfortunately, we * cannot declare it "const", because g_source_new() takes a non-const @@ -117,3 +159,5 @@ MultiSocketMonitor::Dispatch(GSource *_source, monitor.Dispatch(); return true; } + +#endif |