aboutsummaryrefslogtreecommitdiff
path: root/platform/android/thread_jandroid.h
diff options
context:
space:
mode:
authorPedro J. Estébanez2017-08-23 19:18:38 +0200
committerPedro J. Estébanez2017-08-24 07:02:55 +0200
commitd806ad4a3dcf7308147e1a243092d22091560d7d (patch)
tree1aa556f49cb1b6908902387ea122d953aa6d7d45 /platform/android/thread_jandroid.h
parenta560a6211868d517908f44e1ea90336b18cdb97d (diff)
downloadgodot-d806ad4a3dcf7308147e1a243092d22091560d7d.tar.gz
godot-d806ad4a3dcf7308147e1a243092d22091560d7d.tar.zst
godot-d806ad4a3dcf7308147e1a243092d22091560d7d.zip
Implement custom thread numbering for POSIX
For every UNIX-derived (Android, Linux, macOS, iOS) flavor, a global counter is atomically incremented on thread start. That id is kept as thread-local storage. Therefore, thread ids are sequential numbers, trivially comparable. This improves the previous state of things, in which `pthread_t` were casted to `Thread::ID` and unportabily compared. Also big, ugly thread ids appeared.
Diffstat (limited to '')
-rw-r--r--platform/android/thread_jandroid.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/platform/android/thread_jandroid.h b/platform/android/thread_jandroid.h
index 526732974..010ae9ac1 100644
--- a/platform/android/thread_jandroid.h
+++ b/platform/android/thread_jandroid.h
@@ -41,6 +41,9 @@
class ThreadAndroid : public Thread {
+ static pthread_key_t thread_id_key;
+ static ID next_thread_id;
+
pthread_t pthread;
pthread_attr_t pthread_attr;
ThreadCreateCallback callback;