diff options
Diffstat (limited to '')
-rw-r--r-- | test/run_inotify.cxx (renamed from test/run_inotify.c) | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/test/run_inotify.c b/test/run_inotify.cxx index 3e7c70dba..29fcf70ab 100644 --- a/test/run_inotify.c +++ b/test/run_inotify.cxx @@ -18,18 +18,20 @@ */ #include "config.h" -#include "inotify_source.h" +#include "InotifySource.hxx" +#include "event/Loop.hxx" + +#include <glib.h> -#include <stdbool.h> #include <sys/inotify.h> #include <signal.h> -static GMainLoop *main_loop; +static EventLoop *event_loop; static void exit_signal_handler(G_GNUC_UNUSED int signum) { - g_main_loop_quit(main_loop); + event_loop->Break(); } enum { @@ -59,26 +61,25 @@ int main(int argc, char **argv) path = argv[1]; - struct mpd_inotify_source *source = - mpd_inotify_source_new(my_inotify_callback, NULL, - &error); + event_loop = new EventLoop(EventLoop::Default()); + + InotifySource *source = InotifySource::Create(*event_loop, + my_inotify_callback, + nullptr, &error); if (source == NULL) { g_warning("%s", error->message); g_error_free(error); return 2; } - int descriptor = mpd_inotify_source_add(source, path, - IN_MASK, &error); + int descriptor = source->Add(path, IN_MASK, &error); if (descriptor < 0) { - mpd_inotify_source_free(source); + delete source; g_warning("%s", error->message); g_error_free(error); return 2; } - main_loop = g_main_loop_new(NULL, false); - struct sigaction sa; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); @@ -86,8 +87,8 @@ int main(int argc, char **argv) sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); - g_main_loop_run(main_loop); - g_main_loop_unref(main_loop); + event_loop->Run(); - mpd_inotify_source_free(source); + delete source; + delete event_loop; } |