Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor StreamInferHandler for better readability #6257

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/grpc/grpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ CommonCallData<ResponderType, RequestType, ResponseType>::Process(bool rpc_ok)
step_ = Steps::FINISH;
}

return step_ != Steps::FINISH;
return step_ == Steps::FINISH;
}

template <typename ResponderType, typename RequestType, typename ResponseType>
Expand Down Expand Up @@ -338,7 +338,8 @@ CommonHandler::Start()

while (cq_->Next(&tag, &ok)) {
ICallData* call_data = static_cast<ICallData*>(tag);
if (!call_data->Process(ok)) {
const bool tag_finished = call_data->Process(ok);
if (tag_finished) {
LOG_VERBOSE(1) << "Done for " << call_data->Name() << ", "
<< call_data->Id();
delete call_data;
Expand Down
2 changes: 1 addition & 1 deletion src/grpc/infer_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ ModelInferHandler::Process(InferHandler::State* state, bool rpc_ok)
finished = true;
}

return !finished;
return finished;
}

TRITONSERVER_Error*
Expand Down
4 changes: 3 additions & 1 deletion src/grpc/infer_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ class InferHandler : public HandlerBase {
}

virtual void StartNewRequest() = 0;
// Returns whether the request is finished being processed or not.
virtual bool Process(State* state, bool rpc_ok) = 0;
bool ExecutePrecondition(InferHandler::State* state);

Expand Down Expand Up @@ -1037,7 +1038,8 @@ InferHandler<

while (cq_->Next(&tag, &ok)) {
State* state = static_cast<State*>(tag);
if (!Process(state, ok)) {
const bool tag_finished = Process(state, ok);
if (tag_finished) {
LOG_VERBOSE(1) << "Done for " << Name() << ", " << state->unique_id_;
StateRelease(state);
}
Expand Down
Loading