Skip to content

Update web_request_async_multi.cpp#233

Open
George-Creekbed wants to merge 1 commit into
JLospinoso:masterfrom
George-Creekbed:master
Open

Update web_request_async_multi.cpp#233
George-Creekbed wants to merge 1 commit into
JLospinoso:masterfrom
George-Creekbed:master

Conversation

@George-Creekbed

Copy link
Copy Markdown

Inside the constructor for the Request class, resolver.async_resolve captures this within a lambda.
However, the Request object has not yet been created (function is called inside the constructor), so on exit this will be empty. This is solved by moving resolver.async_resolve to its own function member, which allows the constructor to complete creating a Request object.

At this point it's possible to set n_threads{2} in main() and have the program run correctly.
Try it on example.com as it still accepts simple http requests.

Inside the constructor for the `Request` class, `resolver.async_resolve` captures `this` within a lambda.
However, the `Request` object has not yet been created (function is called inside the constructor), so on exit this will be empty. 
This is solved by moving `resolver.async_resolve` to its own function member, which allows the constructor to complete creating a `Request` object.

At this point it's possible to set `n_threads{2}` in main() and have the program run correctly.
Try it on *example.com* as it still accepts simple http requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant