Now await did like this

void rr_await(rr_context *c){ while (uv_run(c->handle->loop, UV_RUN_ONCE) && c->ok==0); } 

We check the flag in the variable every loop. rr_context - a structure with pointers to everything you need in the process.

Is there a standard option in order to wait for the asynchronous function to complete? If a competitive event immediately triggers a procedure that waits for an answer - will there be problems with variables on the stack or will it all be announced on the heap?

  • it didn’t work with libuv, and the documentation is rather scanty, but what you are doing looks at least suspicious, and if you are invoking / rr_await multiple times for one context, almost everything will probably go to hell ... you should probably use other synchronization primitives; which ones depend on the details of the task, in this case the minimum reproducible example for experiments will not interfere. - Fat-Zer
  • @ Fat-Zer, I do not need synchronization! await as a paradigm is not for synchronization. nothing segfolt from a repeated call - nothing is stuck. received responses from the service as many requests. but one context can call several rr_await competitively because it waits for the completion of the first one - eri
  • With the usual await "om, as a paradigm, this way IMHO has nothing to do because it blocks the calling code, i.e. is the usual expectation of some event with an event-loop ... although maybe I just don't understand exactly how you use it ... about the danger - again, not knowing exactly how you use it, it is difficult to evaluate, but in my view, it will almost certainly freeze under certain actions ... - Fat-Zer
  • Suspends the execution of this function, but scrolls the loop - so the program can receive new requests. - eri

0