From ff4cf6c6d1f5ba2fd0716a07f72e6913326c06b8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 30 Jun 2022 11:56:19 +0200 Subject: [PATCH] test/run_inotify: add class Instance --- test/run_inotify.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/run_inotify.cxx b/test/run_inotify.cxx index 816fc70dc..77ddf32a1 100644 --- a/test/run_inotify.cxx +++ b/test/run_inotify.cxx @@ -40,6 +40,13 @@ my_inotify_callback([[maybe_unused]] int wd, unsigned mask, printf("mask=0x%x name='%s'\n", mask, name); } +struct Instance { + EventLoop event_loop; + const ShutdownHandler shutdown_handler{event_loop}; + + InotifySource source{event_loop, my_inotify_callback, nullptr}; +}; + int main(int argc, char **argv) try { const char *path; @@ -51,13 +58,11 @@ try { path = argv[1]; - EventLoop event_loop; - const ShutdownHandler shutdown_handler(event_loop); + Instance instance; - InotifySource source(event_loop, my_inotify_callback, nullptr); - source.Add(path, IN_MASK); + instance.source.Add(path, IN_MASK); - event_loop.Run(); + instance.event_loop.Run(); return EXIT_SUCCESS; } catch (...) {