lock when modifying components (#475)

This commit is contained in:
water111
2021-05-12 22:44:58 -04:00
committed by GitHub
parent 0ab916e122
commit 53a7d6512f
+4
View File
@@ -82,7 +82,9 @@ void subscribe_component() {
throw std::runtime_error("[VM] Cannot add new components when VM is dead!");
}
status_mutex.lock();
++components;
status_mutex.unlock();
// stall component until VM is ready
if (status == Status::Uninited) {
@@ -91,7 +93,9 @@ void subscribe_component() {
}
void unsubscribe_component() {
status_mutex.lock();
--components;
status_mutex.unlock();
vm_dead_cv.notify_all();
}