Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is boost::io_service::post thread safe?

Is it thread safe to post new handlers from within a handler? I.e. Can threads that called the io_service::run() post new Handlers to the same io_service?

Thanks

like image 287
Johannes Gerer Avatar asked Jun 16 '11 08:06

Johannes Gerer


1 Answers

It is safe to post handlers from within a handler for a single instance of an io_service according to the documentation.

Thread Safety

Distinct objects: Safe.

Shared objects: Safe, with the exception that calling reset() while there are unfinished run(), run_one(), poll() or poll_one() calls results in undefined behaviour.

like image 159
Sam Miller Avatar answered Oct 04 '22 05:10

Sam Miller