From b1c293ef72fdab86e3411f78fb5c5785e9efd41c Mon Sep 17 00:00:00 2001 From: Marko Budiselic Date: Thu, 12 Jan 2017 19:42:52 +0100 Subject: [PATCH] Review updates (documentation, namespace naming) --- include/utils/fswatcher.hpp | 8 +++++++- include/utils/linux.hpp | 2 +- tests/unit/fswatcher.cpp | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/utils/fswatcher.hpp b/include/utils/fswatcher.hpp index d4c29ecaa..b4dbc3ca5 100644 --- a/include/utils/fswatcher.hpp +++ b/include/utils/fswatcher.hpp @@ -48,6 +48,12 @@ using os_mask_t = int; */ using in_event_t = struct inotify_event; constexpr uint64_t IN_HEADER_SIZE = sizeof(struct inotify_event); +/** + * The reason why here is 10 is because the memory space for the data + * has to be upfront reserved (C API). I've picked up 10 because it seems like + * a reasonable size and doesn't have to be configurable before compile or run + * time. + */ constexpr uint64_t IN_BUFF_LEN = 10 * (IN_HEADER_SIZE + NAME_MAX + 1); /** @@ -153,7 +159,7 @@ public: inotify_fd_ = inotify_init(); if (inotify_fd_ == -1) throw FSWatcherException("Unable to initialize inotify\n"); - os_linux::set_non_blocking(inotify_fd_); + linux_os::set_non_blocking(inotify_fd_); } ~FSWatcher() diff --git a/include/utils/linux.hpp b/include/utils/linux.hpp index 6806c3081..524b13298 100644 --- a/include/utils/linux.hpp +++ b/include/utils/linux.hpp @@ -19,7 +19,7 @@ #include "utils/exceptions/not_yet_implemented.hpp" #include "utils/likely.hpp" -namespace os_linux +namespace linux_os { class LinuxException : public BasicException { diff --git a/tests/unit/fswatcher.cpp b/tests/unit/fswatcher.cpp index 1e05293f6..196b8086a 100644 --- a/tests/unit/fswatcher.cpp +++ b/tests/unit/fswatcher.cpp @@ -62,7 +62,7 @@ TEST(FSWatcherTest, CreateDeleteLoop) // time distance between two actions should be big enough otherwise // one event will hide another one - ms action_delta = watcher.check_interval() * 2; + ms action_delta = watcher.check_interval() * 3; // watchers watcher.watch(WatchDescriptor(working_dir, FSEventType::Created), @@ -100,7 +100,7 @@ TEST(FSWatcherTest, ModifiyLoop) // parameters int iterations = 10; int modified_no = 0; - ms action_delta = watcher.check_interval() * 2; + ms action_delta = watcher.check_interval() * 3; watcher.watch(WatchDescriptor(working_dir, FSEventType::Modified), [&](FSEvent) { modified_no++; });