1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Drop old semaphore implementation

- Removed platform-specific implementations.
- Now all semaphores are in-object, unless they need to be conditionally created.
- Similarly to `Mutex`, provided a dummy implementation for when `NO_THREADS` is defined.
- Similarly to `Mutex`, methods are made `const` for easy use in such contexts.
- Language bindings updated: `wait()` and `post()` are now `void`.
- Language bindings updated: `try_wait()` added.

Bonus:
- Rewritten the `#ifdef` in `mutex.h` to meet the code style.
This commit is contained in:
Pedro J. Estébanez
2020-03-03 09:26:42 +01:00
parent c9768f15f7
commit 9a3a2b03b8
33 changed files with 79 additions and 803 deletions

View File

@@ -2576,32 +2576,28 @@ void _Marshalls::_bind_methods() {
////////////////
Error _Semaphore::wait() {
void _Semaphore::wait() {
return semaphore->wait();
semaphore.wait();
}
Error _Semaphore::post() {
Error _Semaphore::try_wait() {
return semaphore->post();
return semaphore.try_wait() ? OK : ERR_BUSY;
}
void _Semaphore::post() {
semaphore.post();
}
void _Semaphore::_bind_methods() {
ClassDB::bind_method(D_METHOD("wait"), &_Semaphore::wait);
ClassDB::bind_method(D_METHOD("try_wait"), &_Semaphore::try_wait);
ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post);
}
_Semaphore::_Semaphore() {
semaphore = SemaphoreOld::create();
}
_Semaphore::~_Semaphore() {
memdelete(semaphore);
}
///////////////
void _Mutex::lock() {