r/cpp • • Sep 15 '26

Asynchronous API

https://grishavanika.github.io/async_api.html
36 Upvotes

28 comments sorted by

View all comments

Show parent comment

1

u/grishavanika Sep 20 '26

it is around CURL_async_get intentionally to cover any other C-style API, which, in general case, you dont know the implementstion details. I mentioned at one point that this way you build unoptimized API, causing multiple unneeded allocations, implying building CURL wrapper targetting senders would be better.

Regarding error reporting - CURL API never fails, new is nothrow + assert, so it never fails too, start has no need to hndle exceptions since there are zero

2

u/robertahleahy WG21, SCC, std::execution, Finance Sep 20 '26 edited Sep 20 '26

I don't see how it's the case that "[the] CURL API never fails." It can fail to allocate, it can fail to resolve DNS, it can fail to connect to the remote host, the remote host can send it a corrupt response...

Also this line:

std::string* state = new std::string{};

Can certainly throw std::bad_alloc.

2

u/grishavanika Sep 20 '26

Ah, I dint update the article code (github version is nothrow). The intention was to basically have noexcept CURL_async_get() for simplicity. You are right, will add a point of everything noexcept. Introducing errors handling adds another layer of complexity. I planned to have this discussed separately, but it's too much

2

u/grishavanika Sep 20 '26

updated, thank you