Make DataFacade local to every request

This is the first step to having fine grained locking on data updates,
see issue #2570.
This commit is contained in:
Patrick Niklaus
2016-10-06 01:05:03 +02:00
committed by Patrick Niklaus
parent 66f2cc5184
commit 1c2ead8fb8
21 changed files with 361 additions and 291 deletions
+7 -6
View File
@@ -17,13 +17,14 @@ namespace engine
namespace plugins
{
NearestPlugin::NearestPlugin(datafacade::BaseDataFacade &facade, const int max_results_)
: BasePlugin{facade}, max_results{max_results_}
NearestPlugin::NearestPlugin(const int max_results_)
: max_results{max_results_}
{
}
Status NearestPlugin::HandleRequest(const api::NearestParameters &params,
util::json::Object &json_result)
Status NearestPlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
const api::NearestParameters &params,
util::json::Object &json_result) const
{
BOOST_ASSERT(params.IsValid());
@@ -44,7 +45,7 @@ Status NearestPlugin::HandleRequest(const api::NearestParameters &params,
return Error("InvalidOptions", "Only one input coordinate is supported", json_result);
}
auto phantom_nodes = GetPhantomNodes(params, params.number_of_results);
auto phantom_nodes = GetPhantomNodes(*facade, params, params.number_of_results);
if (phantom_nodes.front().size() == 0)
{
@@ -52,7 +53,7 @@ Status NearestPlugin::HandleRequest(const api::NearestParameters &params,
}
BOOST_ASSERT(phantom_nodes.front().size() > 0);
api::NearestAPI nearest_api(facade, params);
api::NearestAPI nearest_api(*facade, params);
nearest_api.MakeResponse(phantom_nodes, json_result);
return Status::Ok;