This commit is contained in:
+14
-9
@@ -34,8 +34,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../Plugins/TimestampPlugin.h"
|
||||
#include "../Plugins/ViaRoutePlugin.h"
|
||||
|
||||
|
||||
#include "../Server/DataStructures/BaseDataFacade.h"
|
||||
#include "../Server/DataStructures/InternalDataFacade.h"
|
||||
#include "../Server/DataStructures/SharedBarriers.h"
|
||||
#include "../Server/DataStructures/SharedDataFacade.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
@@ -49,6 +50,7 @@ OSRM_impl::OSRM_impl( const ServerPaths & server_paths, const bool use_shared_me
|
||||
server_paths
|
||||
);
|
||||
} else {
|
||||
barrier = new SharedBarriers();
|
||||
query_data_facade = new SharedDataFacade<QueryEdge::EdgeData>( );
|
||||
}
|
||||
|
||||
@@ -82,6 +84,9 @@ OSRM_impl::~OSRM_impl() {
|
||||
BOOST_FOREACH(PluginMap::value_type & plugin_pointer, plugin_map) {
|
||||
delete plugin_pointer.second;
|
||||
}
|
||||
if( use_shared_memory ) {
|
||||
delete barrier;
|
||||
}
|
||||
}
|
||||
|
||||
void OSRM_impl::RegisterPlugin(BasePlugin * plugin) {
|
||||
@@ -103,18 +108,18 @@ void OSRM_impl::RunQuery(RouteParameters & route_parameters, http::Reply & reply
|
||||
// lock update pending
|
||||
boost::interprocess::scoped_lock<
|
||||
boost::interprocess::named_mutex
|
||||
> pending_lock(barrier.pending_update_mutex);
|
||||
> pending_lock(barrier->pending_update_mutex);
|
||||
|
||||
// lock query
|
||||
boost::interprocess::scoped_lock<
|
||||
boost::interprocess::named_mutex
|
||||
> query_lock(barrier.query_mutex);
|
||||
> query_lock(barrier->query_mutex);
|
||||
|
||||
// unlock update pending
|
||||
pending_lock.unlock();
|
||||
|
||||
// increment query count
|
||||
++(barrier.number_of_queries);
|
||||
++(barrier->number_of_queries);
|
||||
|
||||
(static_cast<SharedDataFacade<QueryEdge::EdgeData>* >(query_data_facade))->CheckAndReloadFacade();
|
||||
}
|
||||
@@ -124,18 +129,18 @@ void OSRM_impl::RunQuery(RouteParameters & route_parameters, http::Reply & reply
|
||||
// lock query
|
||||
boost::interprocess::scoped_lock<
|
||||
boost::interprocess::named_mutex
|
||||
> query_lock(barrier.query_mutex);
|
||||
> query_lock(barrier->query_mutex);
|
||||
|
||||
// decrement query count
|
||||
--(barrier.number_of_queries);
|
||||
--(barrier->number_of_queries);
|
||||
BOOST_ASSERT_MSG(
|
||||
0 <= barrier.number_of_queries,
|
||||
0 <= barrier->number_of_queries,
|
||||
"invalid number of queries"
|
||||
);
|
||||
|
||||
// notify all processes that were waiting for this condition
|
||||
if (0 == barrier.number_of_queries) {
|
||||
barrier.no_running_queries_condition.notify_all();
|
||||
if (0 == barrier->number_of_queries) {
|
||||
barrier->no_running_queries_condition.notify_all();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
+5
-3
@@ -34,12 +34,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "../DataStructures/QueryEdge.h"
|
||||
#include "../Plugins/BasePlugin.h"
|
||||
#include "../Server/DataStructures/SharedBarriers.h"
|
||||
#include "../Server/DataStructures/BaseDataFacade.h"
|
||||
#include "../Util/ProgramOptions.h"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
struct SharedBarriers;
|
||||
template<class EdgeDataT>
|
||||
class BaseDataFacade;
|
||||
|
||||
class OSRM_impl : boost::noncopyable {
|
||||
private:
|
||||
typedef boost::unordered_map<std::string, BasePlugin *> PluginMap;
|
||||
@@ -55,7 +57,7 @@ private:
|
||||
void RegisterPlugin(BasePlugin * plugin);
|
||||
PluginMap plugin_map;
|
||||
bool use_shared_memory;
|
||||
SharedBarriers barrier;
|
||||
SharedBarriers * barrier;
|
||||
//base class pointer to the objects
|
||||
BaseDataFacade<QueryEdge::EdgeData> * query_data_facade;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user