beast
beast copied to clipboard
websocket_client_async_ssl_system_executor sample exits before connecting
Boost 1.73 BOOST_BEAST_VERSION 290
Steps necessary to reproduce the problem
Compile and run the Debug x86 configuration in the attached sample with visual studio 2019. This is the same sample as in the boost/beast deployment. Debug x86 has the command line arguments inserted. websocket_client_async_ssl_system_executor.zip
The issue with the sample is the code line 258: net::system_executor().context().join();
Contrary to the comment in the code this does not wait until the system_executor runs out of work but actively invokes scheduler_.work_finished(); which decrements the outstanding_work_ count and stops the scheduler_, resulting in the websocket session ending prematurely.
As I am using the websocket_client_async_ssl_system_executor sample as the basis of my own work how one can wait on the system_executor?
Thanks Markus
Thanks for the heads -up @markus-bonk .
Is there a particular reason you are looking to use the system_executor in preference to an io_context::executor_type?
I only ask because there are moves afoot to remove system_executor from net.ts, as it has some counter-intuitive behaviour traits that can catch out the unwary developer.
The main reason for going for the system_executor is/was that it hides the complete thread implementation/management: it looked like just a case of create the session, initiate it (three lines of code), then let the method do something else and come back later to see what was happening.
This issue has been open for a while with no activity, has it been resolved?
It looks like this issue has either been abandoned or resolved so I will go ahead and close it. Feel free to re-open this issue if you feel it needs attention, or open new issues as needed. Thanks!
This issue has been open for a while with no activity, has it been resolved?
@markus-bonk Can you try using the asio::thread_pool instead?
I experience the same issue, but it presents only on Windows, not on Linux which is odd.
I am ok with removing this example. The system executor is questionable.
I like the ergonomics of system_executor since I don't have to pass it around like the io_context. However it's too buggy to be useful.
Idiomatic ergonomics is to pass an Executor to constructors.