boost::condition_variable::wait
От: enji  
Дата: 23.08.11 07:15
Оценка:
Есть вот такой код в функции потока:

boost::unique_lock<boost::mutex> lock(msImpl.loadData->mutex);
  
try
{  
  while (someFlag)
    conditional_variable.wait(lock); 
}
catch(const boost::thread_interrupted &)
{    
}

// если wait был прерван по interrupt, будет ли ли поток владеть мьютексом тут?


В доке написано:
Effects: Atomically call lock.unlock() and blocks the current thread. The thread will unblock when notified by a call to this->notify_one() or this->notify_all(), or spuriously. When the thread is unblocked (for whatever reason), the lock is reacquired by invoking lock.lock() before the call to wait returns. The lock is also reacquired by invoking lock.lock() if the function exits with an exception.
Postcondition: lock is locked by the current thread.
Throws: boost::thread_resource_error if an error occurs. boost::thread_interrupted if the wait was interrupted by a call to interrupt() on the boost::thread object associated with the current thread of execution.

Postcondition распространяется на случай выбрасывания исключения?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.