Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

schedulling of tasks with boost::strand

I am using boost::spawn for the asynchronous reads. I run an io_service with single thread. Then I have 2 asynchronous reads/sockets, which I boost::spawn with that io_service. Each of the spawn is modifying internal state of another class. so there will be race condition if they are executing concurrently. At the same time I don't want to loose packets with async_read that means I should be continuously reading. Do I need to use strand here or not? If I don't use strand, both the spawns will execute concurrently? If I use strand, as I am using single thread from my application, will there be loss of packets?

Comments