test/run_inotify: add class Instance
This commit is contained in:
parent
a7b7e35512
commit
ff4cf6c6d1
@ -40,6 +40,13 @@ my_inotify_callback([[maybe_unused]] int wd, unsigned mask,
|
|||||||
printf("mask=0x%x name='%s'\n", mask, name);
|
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)
|
int main(int argc, char **argv)
|
||||||
try {
|
try {
|
||||||
const char *path;
|
const char *path;
|
||||||
@ -51,13 +58,11 @@ try {
|
|||||||
|
|
||||||
path = argv[1];
|
path = argv[1];
|
||||||
|
|
||||||
EventLoop event_loop;
|
Instance instance;
|
||||||
const ShutdownHandler shutdown_handler(event_loop);
|
|
||||||
|
|
||||||
InotifySource source(event_loop, my_inotify_callback, nullptr);
|
instance.source.Add(path, IN_MASK);
|
||||||
source.Add(path, IN_MASK);
|
|
||||||
|
|
||||||
event_loop.Run();
|
instance.event_loop.Run();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
Loading…
Reference in New Issue
Block a user