grpc / grpc

The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)

Home Page:https://grpc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AsyncNotifyWhenDone need improve

xiedeacc opened this issue · comments

current, use AsyncNotifyWhenDone is a bad idea, because when AsyncNotifyWhenDone's tag return by Next, user cannot release relative tags before drain out these tags in complete queue, so user must made some record, do some judgment, it's costly and ugly!!!! most importantly, user cannot release relative resource at once. AsyncNotifyWhenDone it's really a bad implement. so I think never call AsyncNotifyWhenDone maybe better than call it, so if AsyncNotifyWhenDone is not so good, why not just delete this function?

AsyncNotifyWhenDone maybe has only one function: tell out cancelled or finished normally for now, if it's really designed to make call IsCancelled safelly, AsyncNotifyWhenDone change to another name maybe better, this name currently misleading

AsyncNotifyWhenDone() is intended to provide asynchronous notification to the application when an RPC is completed due to some out-of-band event, such as cancellation or exceeding the deadline, so that the server can stop devoting any time to processing that RPC. For many applications, it is not sufficient to use IsCancelled(), because that requires the application to explicitly check for cancellation at various points, rather than simply being notified of the cancellation. There is no other way to address that use case without AsyncNotifiyWhenDone(), which is why we support that API.

Stepping back a bit, note that the new C++ callback API is much easier to use than the CQ-based API, and you will probably find it much easier to understand. In the long run, we would encourage all users to migrate from the CQ-based API to the new callback API.

thanks very much, but from docs, callback api not so efficent as CQ-based api, so I'd prefer CQ-based api