1 #include "import_manager.h"
2 
IsInitialImport(const std::string & path)3 bool ImportManager::IsInitialImport(const std::string& path) {
4   // Try reading the value
5   {
6     std::shared_lock<std::shared_timed_mutex> lock(initial_import_mutex_);
7     if (initial_import_.find(path) != initial_import_.end())
8       return false;
9   }
10 
11   // Try inserting the value
12   {
13     std::unique_lock<std::shared_timed_mutex> lock(initial_import_mutex_);
14     return initial_import_.insert(path).second;
15   }
16 }
17 
TryMarkDependencyImported(const std::string & path)18 bool ImportManager::TryMarkDependencyImported(const std::string& path) {
19   // Try reading the value
20   {
21     std::shared_lock<std::shared_timed_mutex> lock(dependency_mutex_);
22     if (dependency_imported_.find(path) != dependency_imported_.end())
23       return false;
24   }
25 
26   // Try inserting the value
27   {
28     std::unique_lock<std::shared_timed_mutex> lock(dependency_mutex_);
29     return dependency_imported_.insert(path).second;
30   }
31 }
32 
StartQueryDbImport(const std::string & path)33 bool ImportManager::StartQueryDbImport(const std::string& path) {
34   return querydb_processing_.insert(path).second;
35 }
36 
DoneQueryDbImport(const std::string & path)37 void ImportManager::DoneQueryDbImport(const std::string& path) {
38   querydb_processing_.erase(path);
39 }
40