Hi there,
I have a general interest in the following question and would like to hear your opinion.
Setting: Imagine an API that provides a Callback-Interface Cb, that is you can create a Cb object and register it on the API. The API will call methods of your object in some other thread.
This could be the case where you want to receive asynchronous answers from some network service.
Imagine further you as the API client can choose to stop the API giving you answers. Naturally you will want to delete your Cb object after that because it is now useless.
Question: In your opinion does it belong the the duties of the API to check whether you as the client are blocking in one of the callback methods and to delay return from the disconnect procedure until after you have finished?
The problem is that a client has no control of how long the callback method runs. It the disconnect procedure may return before the client is done and the client decides upon that return to delete the Cb object, segfaults may occur because the context of the callback thread is gone.
In my opinion that handling should be cleanly implemented in the API to make it unnecessary for each client to implement that stuff itself.
What is your opinion? Cheers, bbb