Add exception safety to Runtime::Acquire.

Change-Id: Ia2a9baf08bb56971412f1ac3914592612de5f134
This commit is contained in:
Sean Keely
2018-02-28 05:20:07 -06:00
parent 81c923b26f
commit 31c05d2fc7
+2 -1
View File
@@ -108,16 +108,17 @@ hsa_status_t Runtime::Acquire() {
}
runtime_singleton_->ref_count_++;
MAKE_NAMED_SCOPE_GUARD(refGuard, [&]() { runtime_singleton_->ref_count_--; });
if (runtime_singleton_->ref_count_ == 1) {
hsa_status_t status = runtime_singleton_->Load();
if (status != HSA_STATUS_SUCCESS) {
runtime_singleton_->ref_count_--;
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
}
}
refGuard.Dismiss();
return HSA_STATUS_SUCCESS;
}