mirror of
https://github.com/tiennm99/godot.git
synced 2026-08-14 04:25:49 +00:00
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:
+4
-12
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user