diff --git a/CHANGELOG.md b/CHANGELOG.md index bce45103c3..b67841c9cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - NodeJS: - CHANGED: Use node-api instead of NAN. [#6452](/~https://github.com/Project-OSRM/osrm-backend/pull/6452) - Misc: + - CHANGED: Use thread_local instead of boost::thread_specific_ptr. [#6991](/~https://github.com/Project-OSRM/osrm-backend/pull/6991) - CHANGED: Bump flatbuffers to v24.3.25 version. [#6988](/~https://github.com/Project-OSRM/osrm-backend/pull/6988) - CHANGED: Add .reserve(...) to assembleGeometry function. [#6983](/~https://github.com/Project-OSRM/osrm-backend/pull/6983) - CHANGED: Get rid of boost::optional leftovers. [#6977](/~https://github.com/Project-OSRM/osrm-backend/pull/6977) diff --git a/include/engine/search_engine_data.hpp b/include/engine/search_engine_data.hpp index 16ffa25b13..30d8e7c192 100644 --- a/include/engine/search_engine_data.hpp +++ b/include/engine/search_engine_data.hpp @@ -5,8 +5,6 @@ #include "util/query_heap.hpp" #include "util/typedefs.hpp" -#include - namespace osrm::engine { @@ -45,19 +43,19 @@ template <> struct SearchEngineData ManyToManyHeapData, util::UnorderedMapStorage>; - using SearchEngineHeapPtr = boost::thread_specific_ptr; + using SearchEngineHeapPtr = std::unique_ptr; - using ManyToManyHeapPtr = boost::thread_specific_ptr; + using ManyToManyHeapPtr = std::unique_ptr; - static SearchEngineHeapPtr forward_heap_1; - static SearchEngineHeapPtr reverse_heap_1; - static SearchEngineHeapPtr forward_heap_2; - static SearchEngineHeapPtr reverse_heap_2; - static SearchEngineHeapPtr forward_heap_3; - static SearchEngineHeapPtr reverse_heap_3; - static ManyToManyHeapPtr many_to_many_heap; - static SearchEngineHeapPtr map_matching_forward_heap_1; - static SearchEngineHeapPtr map_matching_reverse_heap_1; + static thread_local SearchEngineHeapPtr forward_heap_1; + static thread_local SearchEngineHeapPtr reverse_heap_1; + static thread_local SearchEngineHeapPtr forward_heap_2; + static thread_local SearchEngineHeapPtr reverse_heap_2; + static thread_local SearchEngineHeapPtr forward_heap_3; + static thread_local SearchEngineHeapPtr reverse_heap_3; + static thread_local ManyToManyHeapPtr many_to_many_heap; + static thread_local SearchEngineHeapPtr map_matching_forward_heap_1; + static thread_local SearchEngineHeapPtr map_matching_reverse_heap_1; void InitializeOrClearMapMatchingThreadLocalStorage(unsigned number_of_nodes); @@ -127,16 +125,16 @@ template <> struct SearchEngineData MapMatchingMultiLayerDijkstraHeapData, util::TwoLevelStorage>; - using SearchEngineHeapPtr = boost::thread_specific_ptr; - using ManyToManyHeapPtr = boost::thread_specific_ptr; - using MapMatchingHeapPtr = boost::thread_specific_ptr; + using SearchEngineHeapPtr = std::unique_ptr; + using ManyToManyHeapPtr = std::unique_ptr; + using MapMatchingHeapPtr = std::unique_ptr; - static SearchEngineHeapPtr forward_heap_1; - static SearchEngineHeapPtr reverse_heap_1; - static MapMatchingHeapPtr map_matching_forward_heap_1; - static MapMatchingHeapPtr map_matching_reverse_heap_1; + static thread_local SearchEngineHeapPtr forward_heap_1; + static thread_local SearchEngineHeapPtr reverse_heap_1; + static thread_local MapMatchingHeapPtr map_matching_forward_heap_1; + static thread_local MapMatchingHeapPtr map_matching_reverse_heap_1; - static ManyToManyHeapPtr many_to_many_heap; + static thread_local ManyToManyHeapPtr many_to_many_heap; void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes, unsigned number_of_boundary_nodes); @@ -148,4 +146,4 @@ template <> struct SearchEngineData }; } // namespace osrm::engine -#endif // SEARCH_ENGINE_DATA_HPP +#endif // SEARCH_ENGINE_DATA_HPP \ No newline at end of file diff --git a/src/engine/search_engine_data.cpp b/src/engine/search_engine_data.cpp index dd1a053e0e..e749db6c46 100644 --- a/src/engine/search_engine_data.cpp +++ b/src/engine/search_engine_data.cpp @@ -5,16 +5,18 @@ namespace osrm::engine // CH heaps using CH = routing_algorithms::ch::Algorithm; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_2; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_2; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_3; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::map_matching_forward_heap_1; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::map_matching_reverse_heap_1; - -SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap; +thread_local SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1; +thread_local SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1; +thread_local SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_2; +thread_local SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_2; +thread_local SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_3; +thread_local SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3; +thread_local SearchEngineData::SearchEngineHeapPtr + SearchEngineData::map_matching_forward_heap_1; +thread_local SearchEngineData::SearchEngineHeapPtr + SearchEngineData::map_matching_reverse_heap_1; + +thread_local SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap; void SearchEngineData::InitializeOrClearMapMatchingThreadLocalStorage(unsigned number_of_nodes) { @@ -114,11 +116,13 @@ void SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage(unsigne // MLD using MLD = routing_algorithms::mld::Algorithm; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1; -SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1; -SearchEngineData::MapMatchingHeapPtr SearchEngineData::map_matching_forward_heap_1; -SearchEngineData::MapMatchingHeapPtr SearchEngineData::map_matching_reverse_heap_1; -SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap; +thread_local SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1; +thread_local SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1; +thread_local SearchEngineData::MapMatchingHeapPtr + SearchEngineData::map_matching_forward_heap_1; +thread_local SearchEngineData::MapMatchingHeapPtr + SearchEngineData::map_matching_reverse_heap_1; +thread_local SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap; void SearchEngineData::InitializeOrClearMapMatchingThreadLocalStorage( unsigned number_of_nodes, unsigned number_of_boundary_nodes) @@ -178,4 +182,4 @@ void SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage( many_to_many_heap.reset(new ManyToManyQueryHeap(number_of_nodes, number_of_boundary_nodes)); } } -} // namespace osrm::engine +} // namespace osrm::engine \ No newline at end of file