
Hi All,
can anybody explain me please why I get an access violation in the
following code?
And why if I enable the std::cout in the stream_handler destructor the
code work fine without exception?
I'm developing on windows XP, VS 2005.
Regards
Gianni
Here is the code:
#include

can anybody explain me please why I get an access violation in the following code? And why if I enable the std::cout in the stream_handler destructor the code work fine without exception?
Because you've got a race condition between stream_handler (and its private io_service) destruction, which occurs in the main thread, and the internal io_service shut-down process, which occurs in the thread that invokes io_service::run(). std::cout just take long enough to affect this race contdition. To solve the problem, add thread.join() to the destructor.
participants (2)
-
Gianni Ambrosio
-
Igor R