mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
thread renaming
This commit is contained in:
@@ -81,9 +81,9 @@ void ThreadPosix::wait_to_finish_func_posix(Thread* p_thread) {
|
||||
tp->pthread=0;
|
||||
}
|
||||
|
||||
Error ThreadPosix::set_name(const String& p_name) {
|
||||
Error ThreadPosix::set_name_func_posix(const String& p_name) {
|
||||
|
||||
ERR_FAIL_COND_V(pthread == 0, ERR_UNCONFIGURED);
|
||||
pthread_t running_thread = pthread_self();
|
||||
|
||||
#ifdef PTHREAD_NO_RENAME
|
||||
return ERR_UNAVAILABLE;
|
||||
@@ -93,22 +93,15 @@ Error ThreadPosix::set_name(const String& p_name) {
|
||||
#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
|
||||
|
||||
#ifdef PTHREAD_BSD_SET_NAME
|
||||
pthread_set_name_np(pthread, p_name.utf8().get_data());
|
||||
pthread_set_name_np(running_thread, p_name.utf8().get_data());
|
||||
int err = 0; // Open/FreeBSD ignore errors in this function
|
||||
#else
|
||||
int err = pthread_setname_np(pthread, p_name.utf8().get_data());
|
||||
int err = pthread_setname_np(running_thread, p_name.utf8().get_data());
|
||||
#endif // PTHREAD_BSD_SET_NAME
|
||||
|
||||
#endif // PTHREAD_RENAME_SELF
|
||||
@@ -123,7 +116,7 @@ void ThreadPosix::make_default() {
|
||||
create_func=create_func_posix;
|
||||
get_thread_ID_func=get_thread_ID_func_posix;
|
||||
wait_to_finish_func=wait_to_finish_func_posix;
|
||||
|
||||
set_name_func = set_name_func_posix;
|
||||
}
|
||||
|
||||
ThreadPosix::ThreadPosix() {
|
||||
|
||||
Reference in New Issue
Block a user