@@ -182,6 +182,45 @@ request is ready, `wait()` terminates. It also provides negative return code in
182182case of system related fails (e.g. broken or time outed connection). If ` wait() `
183183returns 0, then response is received and expected to be parsed.
184184
185+ ### Waiting for Responses
186+
187+ The connector provides several wait methods. All methods accept an integer ` timeout `
188+ argument with the following semantics:
189+ 1 . If ` timeout > 0 ` , the connector blocks for ` timeout ` ** milliseconds** or until
190+ all required responses are received.
191+ 2 . If ` timeout == 0 ` , the connector decodes all available responsed and returns
192+ immediately.
193+ 3 . If ` timeout == -1 ` , the connector blocks until required responses is received
194+ (basically, no timeout).
195+
196+ All the waiting functions (except for ` waitAny ` , its desctiption will be later)
197+ return 0 on success, -1 in the case of any internal error or when timeout is exceeded.
198+
199+ Method ` wait ` waits for one request, optional argument allows to get result right away
200+ in case of success:
201+ ``` c++
202+ int rc = client.wait(conn, ping, WAIT_TIMEOUT);
203+ int rc = client.wait(conn, ping, WAIT_TIMEOUT, &result);
204+ ```
205+
206+ Method ` waitAll ` waits for all requests of a connection from the passed vector:
207+ ``` c++
208+ int rc = client.waitAll(conn, vector_of_futures, WAIT_TIMEOUT);
209+ ```
210+
211+ Method ` waitCount ` waits until the given connection will receive responses to
212+ any ` future_count ` requests:
213+ ``` c++
214+ int rc = client.waitCount(conn, future_count, WAIT_TIMEOUT);
215+ ```
216+
217+ Method ` waitAny ` is different - it allows to poll all the connections simultaneously.
218+ In the case of success, the function returns a connection that received a response.
219+ In the case of internal error or when timeout is exceeded, returns ` std::nullopt ` .
220+ ``` c++
221+ std::optional<Connection<Buf, NetProvider>> conn_ready = client.waitAny(WAIT_TIMEOUT);
222+ ```
223+
185224### Receiving Responses
186225
187226To get the response when it is ready, we can use ` Connection::getResponse() ` .
0 commit comments