Don't block all requests to switch data

This switchtes the data even if there are requests still running on the
old data. osrm-datastore then waits until all of these old requests have
finished before freeing the old regions.

This also means that osrm-datastore will return with an error if there
is a data update currenlty in progress.
This commit is contained in:
Patrick Niklaus
2016-10-08 01:52:47 +02:00
committed by Patrick Niklaus
parent 1557ff81bc
commit c69545c47a
6 changed files with 150 additions and 85 deletions
+9 -7
View File
@@ -1,27 +1,29 @@
#ifndef SHARED_BARRIERS_HPP
#define SHARED_BARRIERS_HPP
#include <boost/interprocess/sync/named_condition.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>
#include <boost/interprocess/sync/named_sharable_mutex.hpp>
#include <boost/interprocess/sync/named_upgradable_mutex.hpp>
namespace osrm
{
namespace storage
{
struct SharedBarriers
{
SharedBarriers()
: pending_update_mutex(boost::interprocess::open_or_create, "pending_update"),
query_mutex(boost::interprocess::open_or_create, "query")
: current_regions_mutex(boost::interprocess::open_or_create, "current_regions"),
regions_1_mutex(boost::interprocess::open_or_create, "regions_1"),
regions_2_mutex(boost::interprocess::open_or_create, "regions_2")
{
}
// Mutex to protect access to the boolean variable
boost::interprocess::named_mutex pending_update_mutex;
boost::interprocess::named_sharable_mutex query_mutex;
boost::interprocess::named_upgradable_mutex current_regions_mutex;
boost::interprocess::named_sharable_mutex regions_1_mutex;
boost::interprocess::named_sharable_mutex regions_2_mutex;
};
}
}