Commit 33329dcc authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

added margo_wait_any

parent 490c0c15
......@@ -699,6 +699,23 @@ hg_return_t margo_provider_iforward_timed(
hg_return_t margo_wait(
margo_request req);
* @brief Waits for any of the provided requests to complete.
* Note that even if an error occures, index will be set to
* the index of the request for which the error happened.
* This function will correctly ignore requests that are
* equal to MARGO_REQUEST_NULL. If all the requests are
* equal to MARGO_REQUEST_NULL, this function will return
* HG_SUCCESS and set index to count.
* @param req Array of requests
* @param count Number of requests
* @param index index of the request that completed
* @return 0 on success, hg_return_t values on error
hg_return_t margo_wait_any(
size_t count, margo_request* req, size_t* index);
* Test if an operation initiated by a non-blocking
......@@ -1327,6 +1327,38 @@ int margo_test(margo_request req, int* flag)
return ABT_eventual_test(req->eventual, NULL, flag);
hg_return_t margo_wait_any(
size_t count, margo_request* req, size_t* index)
// XXX this is an active loop, we should change it
// when Argobots provide an ABT_eventual_wait_any
size_t i;
int ret;
int flag = 0;
int has_pending_requests = 0;
for(i = 0; i < count; i++) {
if(req[i] == MARGO_REQUEST_NULL)
has_pending_requests = 1;
ret = margo_test(req[i], &flag);
if(ret != ABT_SUCCESS) {
*index = i;
if(flag) {
*index = i;
return margo_wait(req[i]);
goto try_again;
*index = count;
return HG_SUCCESS;
static hg_return_t margo_irespond_internal(
hg_handle_t handle,
void *out_struct,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment