summaryrefslogtreecommitdiffstats
path: root/core/bind/core_bind.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2020-03-03 09:26:42 +0100
committerPedro J. Estébanez <pedrojrulez@gmail.com>2020-03-03 13:20:42 +0100
commit9a3a2b03b8b718409eb26252d742d48091756ef7 (patch)
tree94cc5ae822288ec8b1e098773338498f865b5b77 /core/bind/core_bind.cpp
parentc9768f15f7bb194622b9020ab2614d47ac7e63dd (diff)
downloadredot-engine-9a3a2b03b8b718409eb26252d742d48091756ef7.tar.gz
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.
Diffstat (limited to 'core/bind/core_bind.cpp')
-rw-r--r--core/bind/core_bind.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index b798d732d6..0d8b75bb63 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -2576,30 +2576,26 @@ 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::_bind_methods() {
+void _Semaphore::post() {
- ClassDB::bind_method(D_METHOD("wait"), &_Semaphore::wait);
- ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post);
+ semaphore.post();
}
-_Semaphore::_Semaphore() {
-
- semaphore = SemaphoreOld::create();
-}
-
-_Semaphore::~_Semaphore() {
+void _Semaphore::_bind_methods() {
- memdelete(semaphore);
+ 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);
}
///////////////