Modernize Semaphore

- Based on C++11's `mutex` and `condition_variable`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
This commit is contained in:
Pedro J. Estébanez
2021-02-18 11:58:08 +01:00
parent 4ddcdc031b
commit 8f6a636ae7
37 changed files with 99 additions and 836 deletions
+4 -12
View File
@@ -2689,12 +2689,14 @@ void _Marshalls::_bind_methods() {
Error _Semaphore::wait() {
return semaphore->wait();
semaphore.wait();
return OK; // Can't fail anymore; keep compat
}
Error _Semaphore::post() {
return semaphore->post();
semaphore.post();
return OK; // Can't fail anymore; keep compat
}
void _Semaphore::_bind_methods() {
@@ -2703,16 +2705,6 @@ void _Semaphore::_bind_methods() {
ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post);
}
_Semaphore::_Semaphore() {
semaphore = Semaphore::create();
}
_Semaphore::~_Semaphore() {
memdelete(semaphore);
}
///////////////
void _Mutex::lock() {