
Roland Schwarz wrote:
Christopher Kohlhoff wrote:
I was traveling along this post, but now have another question:
While my thread is waiting in the futures:
T get() const { boost::mutex::scoped_lock lock(mutex_); while (!value_.get() && !exception_.get()) condition_.wait(lock); if (exception_.get()) exception_->raise(); return *value_; }
it will not react to a io_service_.stop(); request.
While I do understand why this is so, I wonder if there is a way to let the future also check for the demuxers stop flag and exit the wait by possibly throwing an error?
A stop() may only be a temporary condition for the io_service. You can subsequently reset the io_service and call run() again. I.e. the stopping of the io_service is a separate issue to whether the future is ultimately fulfilled. It might be more appropriate to use the destruction of the io_service object, since the io_service destructor cleans up all unfinished handler objects. If the handlers in turn hold the associated promise objects then the destruction of all promises can be used to indicate that the future has been abandoned. Cheers, Chris