
28 Sep
2010
28 Sep
'10
9:15 a.m.
On 2010-09-28 10:24, Romain CHANU wrote:
Hi Vivek,
I did a simple program that creates a pool of threads running io_service.run() and calling a function many times (through io_service.post() ) (like the simple program in the website given earlier).
My function accesses / modifies an object (without lock) and the program just crashes.
I am not really sure of the behavior of functions posted to io_service (i.e io_service.post() ) with multiple threads running io_service.run().
Anyone?
if the io_service is running in a threadpool, handlers that are posted may execute at any time from any thread. If you would like to run handlers which access shared resources that need protection, you could consider looking into Asio's strand facility. Rutger