[chaotic-good] Clean up unused requested_read_args in PromiseEndpoint::ReadCallback. (#33848)

This is a clean up PR for discussion in #33257. 
<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
pull/33856/head
nanahpang 2 years ago committed by GitHub
parent 8bdbd96ba8
commit 44864c1589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      src/core/lib/transport/promise_endpoint.cc
  2. 26
      src/core/lib/transport/promise_endpoint.h

@ -68,11 +68,8 @@ void PromiseEndpoint::WriteCallback(absl::Status status) {
write_waker_.Wakeup();
}
void PromiseEndpoint::ReadCallback(
absl::Status status, size_t num_bytes_requested,
absl::optional<
struct grpc_event_engine::experimental::EventEngine::Endpoint::ReadArgs>
requested_read_args) {
void PromiseEndpoint::ReadCallback(absl::Status status,
size_t num_bytes_requested) {
if (!status.ok()) {
// Invalidates all previous reads.
pending_read_buffer_.Clear();
@ -88,18 +85,16 @@ void PromiseEndpoint::ReadCallback(
if (read_buffer_.Length() < num_bytes_requested) {
// A further read is needed.
// Set read args with number of bytes needed as hint.
requested_read_args = {
static_cast<int64_t>(num_bytes_requested - read_buffer_.Length())};
grpc_event_engine::experimental::EventEngine::Endpoint::ReadArgs
read_args = {static_cast<int64_t>(num_bytes_requested -
read_buffer_.Length())};
// If `Read()` returns true immediately, the callback will not be
// called. We still need to call our callback to pick up the result and
// maybe do further reads.
if (endpoint_->Read(std::bind(&PromiseEndpoint::ReadCallback, this,
std::placeholders::_1, num_bytes_requested,
requested_read_args),
&pending_read_buffer_,
&(requested_read_args.value()))) {
ReadCallback(absl::OkStatus(), num_bytes_requested,
requested_read_args);
std::placeholders::_1, num_bytes_requested),
&pending_read_buffer_, &read_args)) {
ReadCallback(absl::OkStatus(), num_bytes_requested);
}
} else {
MutexLock lock(&read_mutex_);

@ -107,16 +107,14 @@ class PromiseEndpoint {
lock.Release();
// Set read args with hinted bytes.
grpc_event_engine::experimental::EventEngine::Endpoint::ReadArgs
read_args;
read_args.read_hint_bytes = num_bytes;
read_args = {static_cast<int64_t>(num_bytes)};
// If `Read()` returns true immediately, the callback will not be
// called. We still need to call our callback to pick up the result and
// maybe do further reads.
if (endpoint_->Read(std::bind(&PromiseEndpoint::ReadCallback, this,
std::placeholders::_1, num_bytes,
absl::nullopt /* uses default arguments */),
std::placeholders::_1, num_bytes),
&pending_read_buffer_, &read_args)) {
ReadCallback(absl::OkStatus(), num_bytes, read_args);
ReadCallback(absl::OkStatus(), num_bytes);
}
} else {
read_result_ = absl::OkStatus();
@ -158,16 +156,15 @@ class PromiseEndpoint {
if (read_buffer_.Length() < num_bytes) {
lock.Release();
// Set read args with num_bytes as hint.
const struct grpc_event_engine::experimental::EventEngine::Endpoint::
ReadArgs read_args = {static_cast<int64_t>(num_bytes)};
grpc_event_engine::experimental::EventEngine::Endpoint::ReadArgs
read_args = {static_cast<int64_t>(num_bytes)};
// If `Read()` returns true immediately, the callback will not be
// called. We still need to call our callback to pick up the result
// and maybe do further reads.
if (endpoint_->Read(
std::bind(&PromiseEndpoint::ReadCallback, this,
std::placeholders::_1, num_bytes, read_args),
&pending_read_buffer_, &read_args)) {
ReadCallback(absl::OkStatus(), num_bytes, read_args);
if (endpoint_->Read(std::bind(&PromiseEndpoint::ReadCallback, this,
std::placeholders::_1, num_bytes),
&pending_read_buffer_, &read_args)) {
ReadCallback(absl::OkStatus(), num_bytes);
}
} else {
read_result_ = absl::OkStatus();
@ -284,10 +281,7 @@ class PromiseEndpoint {
// Callback function used for `EventEngine::Endpoint::Read()` shared between
// `Read()` and `ReadSlice()`.
void ReadCallback(absl::Status status, size_t num_bytes_requested,
absl::optional<struct grpc_event_engine::experimental::
EventEngine::Endpoint::ReadArgs>
requested_read_arg = absl::nullopt);
void ReadCallback(absl::Status status, size_t num_bytes_requested);
// Callback function used for `EventEngine::Endpoint::Read()` in `ReadByte()`.
void ReadByteCallback(absl::Status status);
};

Loading…
Cancel
Save