You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it is not necessary to mix the concepts of asynchronous and multi-threading.
Asynchronous is not about creating parallel threads, but switching between tasks within a thread. Asynchronous can be implemented using coroutines, which were added in C++20.
Example:
If we need to make simultaneous requests, then we can create separate threads for each request. All these threads will be waiting for a response, this is not very efficient if waiting for a response takes a significant part of the time. In this case, it is more efficient to create requests in one thread, and while waiting for a response to one request, process the response to another request. This will allow you to spend less time waiting. In addition, switching between threads is much more expensive than switching between coroutines.
Also, I find it not very efficient to create and delete threads for each new request if the requests need to be sent frequently.
What do you think about it?
Thanks
The text was updated successfully, but these errors were encountered:
We can use std::async also instead of creating a new thread for each new transfer. It may be implemented as thread pool sometimes. Or we can implement own thread pool. It will help reduce the cost of creating threads and improve performance.
Good afternoon.
The wording of the name of this example is a bit confusing
Libusbpp/examples/LibusbTest.cpp
Line 355 in 389ceea
I think it is not necessary to mix the concepts of asynchronous and multi-threading.
Asynchronous is not about creating parallel threads, but switching between tasks within a thread. Asynchronous can be implemented using coroutines, which were added in C++20.
Example:
If we need to make simultaneous requests, then we can create separate threads for each request. All these threads will be waiting for a response, this is not very efficient if waiting for a response takes a significant part of the time. In this case, it is more efficient to create requests in one thread, and while waiting for a response to one request, process the response to another request. This will allow you to spend less time waiting. In addition, switching between threads is much more expensive than switching between coroutines.
Also, I find it not very efficient to create and delete threads for each new request if the requests need to be sent frequently.
What do you think about it?
Thanks
The text was updated successfully, but these errors were encountered: