Closed rbdm-qnt closed 2 years ago
did you try adding "pool.wait_for_tasks();" at the bottom of the main function?
Edit: You can also try changing the callback closure parameter from "(const RestClient::Response& response)" to "(const RestClient::Response response)" to allow the response being passed in to outlive the main function.
Edit2: Move semantics could also fix your issue: "(const RestClient::Response&& response)"
Edit3: I am wrong about Edit2, and there may be issues with my analysis after reading this line: "The lifetime of a temporary object may be extended by binding to a const lvalue reference or to an rvalue reference (since C++11), see reference initialization for details." from here
Sorry, I'm not familiar with restclient-cpp, so I'm not really sure what the problem is. However, I do not believe it is a problem with the thread pool library. This seems to have something to do with how restclient-cpp handles data internally. Hopefully someone on their repo can help.
I'm using your lib and restclient-cpp lib to compile get and post requests and execute them in parallel to the main runtime.
This is an example version of my code:
If I call request.execute() outside of the threadpool, it gets executed normally, while if I call it in the push_task the URL of the request gets modified, it's like if the first few chars in the url string get converted to bytes or something, I can't figure it out. Those are the prints:
Request url in main thread: https://api.bybit.com/private/linear/position/list Pushed to threadpool Inside request.h get. URL: t��t.com/private/linear/position/list
I asked this question in the restclient-cpp repo issues aswell.