diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-03-05 16:33:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-05 16:33:45 +0100 |
commit | 42595085a5a22f3b5399844d06e89631c42e8981 (patch) | |
tree | da1c7092d1b0960891b4634358b1150f679fa805 /core/bind | |
parent | bd553d072b65fe5359ab76e64566ff316d35c62e (diff) | |
parent | 9a3a2b03b8b718409eb26252d742d48091756ef7 (diff) |
Merge pull request #36752 from RandomShaper/rework_semaphore
Drop old semaphore implementation
Diffstat (limited to 'core/bind')
-rw-r--r-- | core/bind/core_bind.cpp | 24 | ||||
-rw-r--r-- | core/bind/core_bind.h | 10 |
2 files changed, 14 insertions, 20 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 264d8d415c..bfe07d61c5 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); } /////////////// diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index e7850de744..fc6419b7d8 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -635,16 +635,14 @@ public: class _Semaphore : public Reference { GDCLASS(_Semaphore, Reference); - SemaphoreOld *semaphore; + Semaphore semaphore; static void _bind_methods(); public: - Error wait(); - Error post(); - - _Semaphore(); - ~_Semaphore(); + void wait(); + Error try_wait(); + void post(); }; class _Thread : public Reference { |