Skip to content

Commit 5942052

Browse files
committed
resolve comments
1 parent 37f3243 commit 5942052

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

src/infer_payload.cc

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ InferPayload::InferPayload(
3232
const bool is_decoupled,
3333
std::function<void(std::unique_ptr<InferResponse>)> callback)
3434
: is_decoupled_(is_decoupled), is_promise_set_(false), callback_(callback),
35-
is_request_deleted_(false),
3635
request_address_(reinterpret_cast<intptr_t>(nullptr))
3736
{
3837
promise_.reset(new std::promise<std::unique_ptr<InferResponse>>());
@@ -96,22 +95,10 @@ InferPayload::ResponseAllocUserp()
9695
void
9796
InferPayload::SetRequestAddress(intptr_t request_address)
9897
{
98+
std::unique_lock<std::mutex> lock(request_address_mutex_);
9999
request_address_ = request_address;
100100
}
101101

102-
intptr_t
103-
InferPayload::GetRequestAddress()
104-
{
105-
return request_address_;
106-
}
107-
108-
void
109-
InferPayload::SetRequestDeleted()
110-
{
111-
std::unique_lock<std::mutex> lock(request_deletion_mutex_);
112-
is_request_deleted_ = true;
113-
}
114-
115102
void
116103
InferPayload::SetRequestCancellationFunc(
117104
const std::function<void(intptr_t)>& request_cancel_func)
@@ -122,11 +109,7 @@ InferPayload::SetRequestCancellationFunc(
122109
void
123110
InferPayload::SafeCancelRequest()
124111
{
125-
std::unique_lock<std::mutex> lock(request_deletion_mutex_);
126-
if (is_request_deleted_) {
127-
return;
128-
}
129-
112+
std::unique_lock<std::mutex> lock(request_address_mutex_);
130113
if (request_address_ == 0L) {
131114
return;
132115
}

src/infer_payload.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ class InferPayload : public std::enable_shared_from_this<InferPayload> {
6262
void SetResponseAllocUserp(
6363
const ResponseAllocatorUserp& response_alloc_userp);
6464
std::shared_ptr<ResponseAllocatorUserp> ResponseAllocUserp();
65-
void SetRequestDeleted();
6665
void SetRequestAddress(intptr_t request_address);
67-
intptr_t GetRequestAddress();
6866
void SetRequestCancellationFunc(
6967
const std::function<void(intptr_t)>& request_cancel_func);
7068
void SafeCancelRequest();
@@ -76,8 +74,7 @@ class InferPayload : public std::enable_shared_from_this<InferPayload> {
7674
bool is_promise_set_;
7775
std::function<void(std::unique_ptr<InferResponse>)> callback_;
7876
std::shared_ptr<ResponseAllocatorUserp> response_alloc_userp_;
79-
std::mutex request_deletion_mutex_;
80-
bool is_request_deleted_;
77+
std::mutex request_address_mutex_;
8178
intptr_t request_address_;
8279
std::function<void(intptr_t)> request_cancel_func_;
8380
};

src/request_executor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ InferRequestComplete(
7171
if (request != nullptr) {
7272
RequestCompletionUserp* completion_userp =
7373
reinterpret_cast<RequestCompletionUserp*>(userp);
74-
completion_userp->infer_payload->SetRequestDeleted();
74+
completion_userp->infer_payload->SetRequestAddress(0L);
7575

7676
LOG_IF_ERROR(
7777
TRITONSERVER_InferenceRequestDelete(request),

0 commit comments

Comments
 (0)