c++ - Calling boost::asio::io_service::run from a std::thread -


i have class handles connection has boost::asio::io_service member. i'm wanting call io_service::run() std::thread, running compilation errors.

std::thread run_thread(&boost::asio::io_service, std::ref(m_io_service)); 

does not work. see various examples out there doing using boost::thread, wanting stick std::thread this. suggestions?

thanks

there 2 ways have known, 1 create std::thread lambda.

std::thread run_thread([&]{ m_io_service.run(); }); 

another create boost::thread boost::bind

boost::thread run_thread(boost::bind(&boost::asio::io_service::run, boost::ref(m_io_service))); 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -