Skip to content

Commit

Permalink
Adding comments to flow, some doc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerin Philip committed Apr 7, 2021
1 parent 5bf29c1 commit 583fce6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/translator/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,27 @@ Service::translateMultiple(std::vector<std::string> &&inputs,
// TODO(jerinphilip) Set options based on TranslationRequest, if and when it
// becomes non-dummy.

// We queue the individual Requests so they get compiled at batches to be
// efficiently translated.
std::vector<std::future<Response>> responseFutures;
for (auto &input : inputs) {
std::future<Response> inputResponse =
queueRequest(std::move(input), responseOptions);
responseFutures.push_back(std::move(inputResponse));
}

// Dispatch is called once per request so compilation of sentences from
// multiple Requests happen.
dispatchTranslate();

// Now wait for all Requests to complete, the future to fire and return the
// compiled Responses, we can probably return the future, but WASM quirks(?).
std::vector<Response> responses;
for (auto &future : responseFutures) {
future.wait();
responses.push_back(std::move(future.get()));
}

return responses;
}

Expand Down

0 comments on commit 583fce6

Please sign in to comment.