Skip to content

Commit

Permalink
put a lock infront of the clear function to make it threadsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoshkaj committed Apr 2, 2018
1 parent f39e37a commit 01e6562
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/engine/search_engine_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "util/query_heap.hpp"
#include "util/typedefs.hpp"

#include <boost/thread/tss.hpp>
// #include <boost/thread/tss.hpp>
#include <boost/thread.hpp>

namespace osrm
{
Expand Down Expand Up @@ -57,6 +58,8 @@ template <> struct SearchEngineData<routing_algorithms::ch::Algorithm>
static ManyToManyHeapPtr many_to_many_heap;
static UnpackingCache unpacking_cache;

boost::shared_mutex _shared_access_across_threads;

void InitializeOrClearFirstThreadLocalStorage(unsigned number_of_nodes);

void InitializeOrClearSecondThreadLocalStorage(unsigned number_of_nodes);
Expand Down
1 change: 1 addition & 0 deletions src/engine/search_engine_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ void SearchEngineData<CH>::InitializeOrClearManyToManyThreadLocalStorage(unsigne

void SearchEngineData<CH>::InitializeOrClearUnpackingCacheGlobalStorage(unsigned timestamp)
{
boost::unique_lock<boost::shared_mutex> lock(_shared_access_across_threads);
unpacking_cache.Clear(timestamp);
}

Expand Down

0 comments on commit 01e6562

Please sign in to comment.