Skip to content

Asynchronous/Threaded Transfers #11

@gggrafff

Description

@gggrafff

Good afternoon.
The wording of the name of this example is a bit confusing

std::wcout << L"Test 3 - Asynchronous/Threaded Transfers" << std::endl << std::endl;

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions