|
Boost Users : |
Subject: [Boost-users] ASIO HTTP Server 3 Example: sharing stack data between threads
From: Aaron Riekenberg (aaron.riekenberg_at_[hidden])
Date: 2010-05-22 17:38:36
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net