Receive a response from the Data Plane, awaiting if none available.
(&mut self)
| 119 | |
| 120 | /// Receive a response from the Data Plane, awaiting if none available. |
| 121 | pub async fn recv_response(&mut self) -> Result<Rsp> { |
| 122 | // Fast path: try immediate pop. |
| 123 | match self.inner.try_recv_response() { |
| 124 | Ok(rsp) => return Ok(rsp), |
| 125 | Err(BridgeError::Empty) => {} |
| 126 | Err(e) => return Err(e), |
| 127 | } |
| 128 | |
| 129 | // Slow path: wait for data. |
| 130 | loop { |
| 131 | let mut guard = |
| 132 | self.rsp_ready_fd |
| 133 | .readable() |
| 134 | .await |
| 135 | .map_err(|_| BridgeError::Backpressure { |
| 136 | percent: 0, |
| 137 | threshold: 0, |
| 138 | })?; |
| 139 | |
| 140 | let _ = self.inner.rsp_wake.consumer_wake.try_read(); |
| 141 | guard.clear_ready(); |
| 142 | |
| 143 | match self.inner.try_recv_response() { |
| 144 | Ok(rsp) => return Ok(rsp), |
| 145 | Err(BridgeError::Empty) => continue, |
| 146 | Err(e) => return Err(e), |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /// Non-blocking try to receive a response. |
| 152 | pub fn try_recv_response(&mut self) -> Result<Rsp> { |