Skip to content

Commit

Permalink
Ignore duplicated file modifications in a span of three seconds
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
crosire committed Jan 8, 2019
1 parent fad6939 commit 55f2534
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/blink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ void blink::application::run()
if (source_file.extension() != ".cpp")
continue;

// Ignore duplicated notifications by comparing times and skipping any changes that are not older than 3 seconds
if (const auto current_time = GetTickCount(); _last_modifications[source_file.string()] + 3000 > current_time)
continue;
else
_last_modifications[source_file.string()] = current_time;

print("Detected modification to: " + source_file.string());

// Build compiler command line
Expand Down
1 change: 1 addition & 0 deletions source/blink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ namespace blink
std::vector<std::filesystem::path> _object_files;
std::vector<std::vector<std::filesystem::path>> _source_files;
std::unordered_map<std::string, void *> _symbols;
std::unordered_map<std::string, uint32_t> _last_modifications;
};
}

0 comments on commit 55f2534

Please sign in to comment.