InotifySource: use the SocketMonitor class

This commit is contained in:
Max Kellermann
2013-01-15 18:18:02 +01:00
parent 2101daef5a
commit 7071126770
5 changed files with 29 additions and 43 deletions

View File

@@ -20,29 +20,23 @@
#ifndef MPD_INOTIFY_SOURCE_HXX
#define MPD_INOTIFY_SOURCE_HXX
#include "event/SocketMonitor.hxx"
#include "gerror.h"
#include "gcc.h"
#include <glib.h>
typedef void (*mpd_inotify_callback_t)(int wd, unsigned mask,
const char *name, void *ctx);
class InotifySource {
class InotifySource final : private SocketMonitor {
mpd_inotify_callback_t callback;
void *callback_ctx;
int fd;
GIOChannel *channel;
/**
* The channel's source id in the GLib main loop.
*/
guint id;
struct fifo_buffer *buffer;
InotifySource(mpd_inotify_callback_t callback, void *ctx, int fd);
InotifySource(EventLoop &_loop,
mpd_inotify_callback_t callback, void *ctx, int fd);
public:
/**
@@ -51,7 +45,8 @@ public:
*
* @param a callback invoked for events received from the kernel
*/
static InotifySource *Create(mpd_inotify_callback_t callback,
static InotifySource *Create(EventLoop &_loop,
mpd_inotify_callback_t callback,
void *ctx,
GError **error_r);
@@ -73,9 +68,7 @@ public:
void Remove(unsigned wd);
private:
void InEvent();
static gboolean InEvent(GIOChannel *source, GIOCondition condition,
gpointer data);
virtual void OnSocketReady(unsigned flags) override;
};
#endif