summaryrefslogtreecommitdiffstats
path: root/core/core_bind.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2021-02-10 19:22:13 +0100
committerPedro J. Estébanez <pedrojrulez@gmail.com>2021-02-18 17:12:46 +0100
commit8e128726f0eac1982aa75a005554ee5b556b332e (patch)
tree827c2f478e8fb3196ef411f4941fa4e839642e31 /core/core_bind.cpp
parent8870f43d742e0c48ae543d999856f5989170b62d (diff)
downloadredot-engine-8e128726f0eac1982aa75a005554ee5b556b332e.tar.gz
Modernize atomics
- Based on C++11's `atomic` - Reworked `SafeRefCount` (based on the rewrite by @hpvb) - Replaced free atomic functions by the new `SafeNumeric<T>` - Replaced wrong cases of `volatile bool` by the new `SafeFlag` - Platform-specific implementations no longer needed Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
Diffstat (limited to 'core/core_bind.cpp')
-rw-r--r--core/core_bind.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index dd99c32fa8..fe49899aa2 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -1990,7 +1990,7 @@ void _Thread::_start_func(void *ud) {
}
Error _Thread::start(Object *p_instance, const StringName &p_method, const Variant &p_userdata, Priority p_priority) {
- ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "Thread already started.");
+ ERR_FAIL_COND_V_MSG(active.is_set(), ERR_ALREADY_IN_USE, "Thread already started.");
ERR_FAIL_COND_V(!p_instance, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_method == StringName(), ERR_INVALID_PARAMETER);
ERR_FAIL_INDEX_V(p_priority, PRIORITY_MAX, ERR_INVALID_PARAMETER);
@@ -1999,7 +1999,7 @@ Error _Thread::start(Object *p_instance, const StringName &p_method, const Varia
target_method = p_method;
target_instance = p_instance;
userdata = p_userdata;
- active = true;
+ active.set();
Ref<_Thread> *ud = memnew(Ref<_Thread>(this));
@@ -2015,14 +2015,14 @@ String _Thread::get_id() const {
}
bool _Thread::is_active() const {
- return active;
+ return active.is_set();
}
Variant _Thread::wait_to_finish() {
- ERR_FAIL_COND_V_MSG(!active, Variant(), "Thread must be active to wait for its completion.");
+ ERR_FAIL_COND_V_MSG(!active.is_set(), Variant(), "Thread must be active to wait for its completion.");
thread.wait_to_finish();
Variant r = ret;
- active = false;
+ active.clear();
target_method = StringName();
target_instance = nullptr;
userdata = Variant();