1 Feb
2015
1 Feb
'15
1:41 p.m.
I've written code of the form: Code: io_service svc; io_service::work work(svc); thread t1( [&svc]() { svc.run(); } ); thread t2( [&svc]() { svc.run(); } ); thread t3( [&svc]() { svc.run(); } ); endpoint ep(ip::tcp::v4(), port); acceptor acceptor(svc, ep); while (true) { shared_ptr<socket> sock(new socket(svc)); acceptor.accept(*sock); svc.post( [sock]() { /* do stuff on sock here */ }); } Is this way of using io_service for accepting tcp connections and also as a thread pool for serving connected clients valid or could I hit some undefined behavior. -- Aaron Levy aaron.levy@yandex.com