-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usability: Decouple API from thread model #100
Comments
For some ops, e.g., I have proposed another appoarch in #12, where a seperate thread pool will be associated to a client, and the thread pool will be destroyed once the client got destructed. How do you think about such solution ? BTW may I know the background about why you need to avoiding creating thread? |
My use case is a distributed system. Depending on the platform, there may be limited threads while most are needed for other purposes. Beyond that, forcing a particular threading model reduces usability across all use cases. The API could be refactored to expect functions to be called within threads created by the application. True downsides of the present approach include assumptions around signal handling, size of thread pool, and number of dependencies. Are the threads created using the parents signal mask or with all blocked? How might that affect an application? Size of thread pool relative to the CPU and competing priorities? Do one thing really well and provide an interface for others to do an additional thing on top. In other words, there’s no reason the thread model need be tied to the implementation of the client. |
Re #12, a compromise would be to allow the consumer of the API to provide an implementation of a thread pool interface, thereby allowing the application to control thread creation. I still feel removal of threading from the library entirely is the better approach. |
Agree with the points above. I will try to revise the implementation the I have try to split a build target Thanks for the insights, your driven cases has convinced me. |
BTW supporting the users to "provide a thread pool interface" won't happen soon, IMO, as we requires cpprestsdk to work, it will initialize its own boost thread pool, and I haven't find a good alternative for the |
What I'm saying is that cpprestsdk should be removed from the library and left to the consumer to decide whether to use it. That said, there are sufficient differences in approach that I will need to move forward with a separate implementation. |
Yes. In my previous comment, where the And an extra wrapper Here |
The decouple of API and thread model is implemented and documented in #130 |
The current architecture forces a specific thread model that does not suite all situations. I would like to see threads moved out of the library, allowing the application to decide on the thread model to utilize.
An alternative could be to support two model, one with threads and one without. But, I think offering the async thread model as a separate library that builds on top of this one would be best. I know there is already SyncClient, but its composed of the async client, meaning the thread pool is still created and used.
The text was updated successfully, but these errors were encountered: