Ticket #57109: shared_timed_mutex.patch

File shared_timed_mutex.patch, 2.0 KB (added by rurban (Reini Urban), 6 years ago)
  • src/import_manager.cc

    diff --git src/import_manager.cc src/import_manager.cc
    index 7d7d9ade..db1caf9e 100644
     
    33bool ImportManager::IsInitialImport(const std::string& path) {
    44  // Try reading the value
    55  {
    6     std::shared_lock<std::shared_timed_mutex> lock(initial_import_mutex_);
     6    std::lock_guard<std::mutex> lock(initial_import_mutex_);
    77    if (initial_import_.find(path) != initial_import_.end())
    88      return false;
    99  }
    1010
    1111  // Try inserting the value
    1212  {
    13     std::unique_lock<std::shared_timed_mutex> lock(initial_import_mutex_);
     13    std::unique_lock<std::mutex> lock(initial_import_mutex_);
    1414    return initial_import_.insert(path).second;
    1515  }
    1616}
    bool ImportManager::IsInitialImport(const std::string& path) { 
    1818bool ImportManager::TryMarkDependencyImported(const std::string& path) {
    1919  // Try reading the value
    2020  {
    21     std::shared_lock<std::shared_timed_mutex> lock(dependency_mutex_);
     21    std::lock_guard<std::mutex> lock(dependency_mutex_);
    2222    if (dependency_imported_.find(path) != dependency_imported_.end())
    2323      return false;
    2424  }
    2525
    2626  // Try inserting the value
    2727  {
    28     std::unique_lock<std::shared_timed_mutex> lock(dependency_mutex_);
     28    std::unique_lock<std::mutex> lock(dependency_mutex_);
    2929    return dependency_imported_.insert(path).second;
    3030  }
    3131}
  • src/import_manager.h

    diff --git src/import_manager.h src/import_manager.h
    index 07fe6272..f00c7141 100644
     
    11#pragma once
    22
    3 #include <shared_mutex>
     3#include <mutex>
    44#include <string>
    55#include <unordered_set>
    66
    struct ImportManager { 
    2727  std::unordered_set<std::string> querydb_processing_;
    2828
    2929  // TODO: use shared_mutex
    30   std::shared_timed_mutex dependency_mutex_;
     30  std::mutex dependency_mutex_;
    3131  std::unordered_set<std::string> dependency_imported_;
    3232
    3333  // TODO: use shared_mutex
    34   std::shared_timed_mutex initial_import_mutex_;
     34  std::mutex initial_import_mutex_;
    3535  std::unordered_set<std::string> initial_import_;
    36 };
    37  No newline at end of file
     36};