In this scenario:
1 2 3 4 5 6
|
try {
std::lock_guard<std::mutex> guard(mutex_defined_somewhere_else);
return map_accessible_in_another_thread[index]; // Exception could be thrown here.
} catch (std::out_of_range) {
throw more_informative_exception_type("Requested resource hasn't been loaded yet");
}
|
Will the mutex be unlocked if an exception is thrown before the end of the try statement?
[edit]Note: In case it wasn't obvious, the mutex locks access to the std::map being indexed into.[/edit]
Last edited on