| 79 | |
| 80 | template <class Handler> |
| 81 | void reader(agrpc::GenericServerRPC& rpc, Channel& channel, const asio::basic_yield_context<Handler>& yield) |
| 82 | { |
| 83 | while (true) |
| 84 | { |
| 85 | grpc::ByteBuffer buffer; |
| 86 | if (!rpc.read(buffer, yield)) |
| 87 | { |
| 88 | std::cout << "Generic: Client is done writing." << std::endl; |
| 89 | break; |
| 90 | } |
| 91 | // Send request to writer. The `max_buffer_size` of the channel acts as backpressure. |
| 92 | boost::system::error_code ec; |
| 93 | channel.async_send(boost::system::error_code{}, std::move(buffer), yield[ec]); |
| 94 | } |
| 95 | // Signal the writer to complete. |
| 96 | channel.close(); |
| 97 | } |
| 98 | |
| 99 | // The writer will pick up reads from the reader through the channel and switch |
| 100 | // to the thread_pool to compute their response. |
no test coverage detected