Skip to content

Commit 92da73b

Browse files
committed
Merge pull request #138 from valhalla/kk_service
do the cleanup on the workers own time so clients arent affected by i…
2 parents 283c065 + 689b521 commit 92da73b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/thor/service.cc

+7-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ namespace {
7777

7878
// Form output information based on path edges
7979
auto trip_path = thor::TripPathBuilder::Build(reader, path_edges, origin, destination);
80-
path_algorithm.Clear();
81-
locations.clear();
8280

8381
//pass it on
8482
worker_t::result_t result{true};
@@ -142,6 +140,10 @@ namespace {
142140
}
143141
cost = factory.Create(costing, config_costing);
144142
}
143+
void cleanup() {
144+
path_algorithm.Clear();
145+
locations.clear();
146+
}
145147
protected:
146148
boost::property_tree::ptree config;
147149
std::vector<Location> locations;
@@ -165,8 +167,10 @@ namespace valhalla {
165167

166168
//listen for requests
167169
zmq::context_t context;
170+
thor_worker_t thor_worker(config);
168171
prime_server::worker_t worker(context, upstream_endpoint, downstream_endpoint, loopback_endpoint,
169-
std::bind(&thor_worker_t::work, thor_worker_t(config), std::placeholders::_1, std::placeholders::_2));
172+
std::bind(&thor_worker_t::work, std::ref(thor_worker), std::placeholders::_1, std::placeholders::_2),
173+
std::bind(&thor_worker_t::cleanup, std::ref(thor_worker)));
170174
worker.work();
171175

172176
//TODO: should we listen for SIGINT and terminate gracefully/exit(0)?

0 commit comments

Comments
 (0)