bool AcsAgentClientReactor::AddRequest()

in cpp/acs_agent_client_reactor.cc [222:240]


bool AcsAgentClientReactor::AddRequest(const Request& request) {
  absl::MutexLock lock(&request_mtx_);
  if (msg_request_ == nullptr) {
    // Add the new request to the buffer of reactor, as the last msg_request_
    // was completed.
    msg_request_ = std::make_unique<Request>(request);
    if (!writing_) {
      NextWrite();
    }
    return true;
  } else {
    // Return false as the last msg_request_ was not completed.
    ABSL_VLOG(1) << absl::StrFormat(
        "Failed to add request of id: %s to the buffer of reactor. The last "
        "request of id: %s is not written to the stream yet.",
        msg_request_->message_id(), msg_request_->message_id());
    return false;
  }
}