I am trying to implement a thread_pool so that each time a CallData arrives from the completion queue, I queue a task to the thread pool so that a thread can get it from a thread safe queue.
Can anybody tell me more about these codes which appear in cpp test files:
do {
ctx = detag(got_tag);
...
} while (some_cq_for_this_thread->DoThenAsyncNext(lambda))
The lambda doing the following things:
take in : ctx (CallData), ok (bool), mu_ptr (std::mutex*)
The body of the lambda triggers an invoker (a specific async rpc method handler derived from some sync ServiceImpl) and re-initiates the async request method.
Something unpleasant to me:
First, in demo, we will check a state, it seems that we don't have to and the demo is misleading. I personally love using such a method pointer to exchange next_state so that we can finish initiate a method and handle it recursively.
Second, I have no idea how DoThenAsyncNext works. Why don't we use a forever loop?
Third, the double locks are tricky here
Finally,