| 52 | }; |
| 53 | |
| 54 | void *Thread::thread_callback(void *p_data) { |
| 55 | ThreadData *thread_data = static_cast<ThreadData *>(p_data); |
| 56 | |
| 57 | // Set the caller ID for this thread |
| 58 | caller_id = thread_data->caller_id; |
| 59 | |
| 60 | ScriptServer::thread_enter(); // Scripts may need to attach a stack. |
| 61 | |
| 62 | // Call the actual callback |
| 63 | thread_data->callback(thread_data->userdata); |
| 64 | |
| 65 | ScriptServer::thread_exit(); |
| 66 | |
| 67 | // Clean up |
| 68 | memdelete(thread_data); |
| 69 | |
| 70 | return nullptr; |
| 71 | } |
| 72 | |
| 73 | Error Thread::set_name(const String &p_name) { |
| 74 | int err = pthread_setname_np(p_name.utf8().get_data()); |