summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorShadowNinja <ShadowNinja@users.noreply.github.com>2017-06-11 03:43:05 -0400
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-06-11 09:43:05 +0200
commit6c5e5e202394ce8063e3c2d9b663145bc4f8efce (patch)
tree2916ed7f7fc19c934fe5f614a9eeb1a282f13081 /src/script
parent5cc8ad946efb3612eb6ea8655780b29fe4c62e19 (diff)
downloadminetest-6c5e5e202394ce8063e3c2d9b663145bc4f8efce.tar.gz
minetest-6c5e5e202394ce8063e3c2d9b663145bc4f8efce.tar.bz2
minetest-6c5e5e202394ce8063e3c2d9b663145bc4f8efce.zip
Remove threads.h and replace its definitions with their C++11 equivalents (#5957)
This also changes threadProc's signature, since C++11 supports arbitrary thread function signatures.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/cpp_api/s_base.h4
-rw-r--r--src/script/cpp_api/s_internal.h16
2 files changed, 11 insertions, 9 deletions
diff --git a/src/script/cpp_api/s_base.h b/src/script/cpp_api/s_base.h
index eda4e73ac..ed056db31 100644
--- a/src/script/cpp_api/s_base.h
+++ b/src/script/cpp_api/s_base.h
@@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iostream>
#include <string>
+#include <thread>
#include "util/basic_macros.h"
extern "C" {
@@ -29,7 +30,6 @@ extern "C" {
}
#include "irrlichttypes.h"
-#include "threads.h"
#include "threading/mutex_auto_lock.h"
#include "common/c_types.h"
#include "common/c_internal.h"
@@ -122,7 +122,7 @@ protected:
bool m_secure;
#ifdef SCRIPTAPI_LOCK_DEBUG
int m_lock_recursion_count;
- threadid_t m_owning_thread;
+ std::thread::id m_owning_thread;
#endif
private:
diff --git a/src/script/cpp_api/s_internal.h b/src/script/cpp_api/s_internal.h
index 37473c497..315561e08 100644
--- a/src/script/cpp_api/s_internal.h
+++ b/src/script/cpp_api/s_internal.h
@@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef S_INTERNAL_H_
#define S_INTERNAL_H_
+#include <thread>
#include "common/c_internal.h"
#include "cpp_api/s_base.h"
@@ -35,23 +36,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class LockChecker {
public:
- LockChecker(int *recursion_counter, threadid_t *owning_thread)
+ LockChecker(int *recursion_counter, std::thread::id *owning_thread)
{
m_lock_recursion_counter = recursion_counter;
m_owning_thread = owning_thread;
m_original_level = *recursion_counter;
- if (*m_lock_recursion_counter > 0)
- assert(thr_is_current_thread(*m_owning_thread));
- else
- *m_owning_thread = thr_get_current_thread_id();
+ if (*m_lock_recursion_counter > 0) {
+ assert(*m_owning_thread == std::this_thread::get_id());
+ } else {
+ *m_owning_thread = std::this_thread::get_id();
+ }
(*m_lock_recursion_counter)++;
}
~LockChecker()
{
- assert(thr_is_current_thread(*m_owning_thread));
+ assert(*m_owning_thread == std::this_thread::get_id());
assert(*m_lock_recursion_counter > 0);
(*m_lock_recursion_counter)--;
@@ -62,7 +64,7 @@ public:
private:
int *m_lock_recursion_counter;
int m_original_level;
- threadid_t *m_owning_thread;
+ std::thread::id *m_owning_thread;
};
#define SCRIPTAPI_LOCK_CHECK \