
22 May
2010
22 May
'10
9:38 p.m.
I was reading through the ASIO HTTP Server 3 example (http://tinyurl.com/35hwtd5) that uses a thread pool to call io_service::run. In both posix_main.cpp and win_main.cpp an http::server3::server object is created on the stack in main(). server has a boost::asio::io_service member (io_service_). main calls server::run, which creates a pool of threads that each call io_service_.run. So at this point the io_service_ object is within main's stack is being shared by multiple threads. Am I missing something or is this a bad thing to do and encourage others to copy? Seems like a simple fix would be to allocate the server object in main on the heap. Thanks, Aaron Riekenberg