I just found a very nice solution myself:
Instead of removing work (resetting _ioServiceWork
) in stop()
, I do it at the end of stop_internal()
. This means that _ioServiceThread->join()
blocks until stop_internal()
has finished - exactly what I want.
The nice thing about this solution is that it doesn't need any mutex or condition variable or stuff like this.