summaryrefslogtreecommitdiffstats
path: root/drivers/unix/thread_posix.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-12-21 09:07:06 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-12-21 09:07:06 -0300
commit15429d6ac95acb044c9eebd64356f33e7e5d14ef (patch)
tree872a375b64d93fd6aaf1239e058a13630c9cfabe /drivers/unix/thread_posix.cpp
parent81f62fb78c7f3c133ef764a99dcdf05077d8ced9 (diff)
parentb2f670ebaefa16b0345f9a7ae825f78dbfdec9f8 (diff)
downloadredot-engine-15429d6ac95acb044c9eebd64356f33e7e5d14ef.tar.gz
Merge branch 'master' of https://github.com/godotengine/godot
Diffstat (limited to 'drivers/unix/thread_posix.cpp')
-rw-r--r--drivers/unix/thread_posix.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index 03963a9756..b7bcd44783 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -45,8 +45,8 @@ Thread* ThreadPosix::create_thread_posix() {
void *ThreadPosix::thread_callback(void *userdata) {
ThreadPosix *t=reinterpret_cast<ThreadPosix*>(userdata);
- t->callback(t->user);
t->id=(ID)pthread_self();
+ t->callback(t->user);
return NULL;
}
@@ -77,6 +77,30 @@ void ThreadPosix::wait_to_finish_func_posix(Thread* p_thread) {
tp->pthread=0;
}
+Error ThreadPosix::set_name(const String& p_name) {
+
+ ERR_FAIL_COND_V(pthread == 0, ERR_UNCONFIGURED);
+
+ #ifdef PTHREAD_RENAME_SELF
+
+ // check if thread is the same as caller
+ int caller = Thread::get_caller_ID();
+ int self = get_ID();
+ if (caller != self) {
+ ERR_EXPLAIN("On this platform, thread can only be renamed with calls from the threads to be renamed.");
+ ERR_FAIL_V(ERR_UNAVAILABLE);
+ return ERR_UNAVAILABLE;
+ };
+ int err = pthread_setname_np(p_name.utf8().get_data());
+
+ #else
+
+ int err = pthread_setname_np(pthread, p_name.utf8().get_data());
+
+ #endif
+
+ return err == 0 ? OK : ERR_INVALID_PARAMETER;
+};
void ThreadPosix::make_default() {