Merge pull request #18460 from AspirinSJL/fix_route_guide

Fix route guide example
pull/18641/head
Juanli Shen 6 years ago committed by GitHub
commit 68a2277121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      examples/cpp/route_guide/route_guide_server.cc

@ -151,24 +151,25 @@ class RouteGuideImpl final : public RouteGuide::Service {
Status RouteChat(ServerContext* context,
ServerReaderWriter<RouteNote, RouteNote>* stream) override {
std::vector<RouteNote> received_notes;
RouteNote note;
while (stream->Read(&note)) {
for (const RouteNote& n : received_notes) {
std::unique_lock<std::mutex> lock(mu_);
for (const RouteNote& n : received_notes_) {
if (n.location().latitude() == note.location().latitude() &&
n.location().longitude() == note.location().longitude()) {
stream->Write(n);
}
}
received_notes.push_back(note);
received_notes_.push_back(note);
}
return Status::OK;
}
private:
std::vector<Feature> feature_list_;
std::mutex mu_;
std::vector<RouteNote> received_notes_;
};
void RunServer(const std::string& db_path) {

Loading…
Cancel
Save