diff --git a/src/core/lib/transport/promise_endpoint.cc b/src/core/lib/transport/promise_endpoint.cc index 5ce0ba3568e..660d183a647 100644 --- a/src/core/lib/transport/promise_endpoint.cc +++ b/src/core/lib/transport/promise_endpoint.cc @@ -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(num_bytes_requested - read_buffer_.Length())}; + grpc_event_engine::experimental::EventEngine::Endpoint::ReadArgs + read_args = {static_cast(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_); diff --git a/src/core/lib/transport/promise_endpoint.h b/src/core/lib/transport/promise_endpoint.h index dc672548ed1..d80071703d6 100644 --- a/src/core/lib/transport/promise_endpoint.h +++ b/src/core/lib/transport/promise_endpoint.h @@ -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(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(num_bytes)}; + grpc_event_engine::experimental::EventEngine::Endpoint::ReadArgs + read_args = {static_cast(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 - 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); };