feat: changed all terrain modifiers to use scoped locks
This commit is contained in:
parent
9d48b68db0
commit
d352808154
6 changed files with 209 additions and 218 deletions
27
modules/terrain/shared_mutex.cpp
Normal file
27
modules/terrain/shared_mutex.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include "shared_mutex.h"
|
||||
|
||||
void SharedMutex::lock_shared() {
|
||||
this->lock.lock();
|
||||
this->shared_count++;
|
||||
this->lock.unlock();
|
||||
}
|
||||
|
||||
void SharedMutex::unlock_shared() {
|
||||
this->lock.lock();
|
||||
this->shared_count--;
|
||||
this->lock.unlock();
|
||||
}
|
||||
|
||||
void SharedMutex::lock_exclusive() {
|
||||
while (true) {
|
||||
this->lock.lock();
|
||||
if (this->shared_count == 0) {
|
||||
return;
|
||||
}
|
||||
this->lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void SharedMutex::unlock_exclusive() {
|
||||
this->lock.unlock();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue