diff --git a/Libraries/LibThread/Thread.cpp b/Libraries/LibThread/Thread.cpp index 2e1475ff25..94b5bcd502 100644 --- a/Libraries/LibThread/Thread.cpp +++ b/Libraries/LibThread/Thread.cpp @@ -37,7 +37,7 @@ LibThread::Thread::Thread(Function action, StringView thread_name) LibThread::Thread::~Thread() { - if (m_tid != -1) { + if (m_tid) { dbg() << "trying to destroy a running thread!"; ASSERT_NOT_REACHED(); } @@ -50,8 +50,8 @@ void LibThread::Thread::start() nullptr, [](void* arg) -> void* { Thread* self = static_cast(arg); - int exit_code = self->m_action(); - self->m_tid = -1; + size_t exit_code = self->m_action(); + self->m_tid = 0; pthread_exit((void*)exit_code); return (void*)exit_code; }, @@ -65,10 +65,10 @@ void LibThread::Thread::start() dbg() << "Started a thread, tid = " << m_tid; } -void LibThread::Thread::quit(int code) +void LibThread::Thread::quit(void *code) { - ASSERT(m_tid == gettid()); + ASSERT(m_tid == pthread_self()); - m_tid = -1; - pthread_exit((void*)code); + m_tid = 0; + pthread_exit(code); } diff --git a/Libraries/LibThread/Thread.h b/Libraries/LibThread/Thread.h index 474a17fa42..a89d543e29 100644 --- a/Libraries/LibThread/Thread.h +++ b/Libraries/LibThread/Thread.h @@ -29,6 +29,7 @@ #include #include #include +#include namespace LibThread { @@ -40,11 +41,11 @@ public: virtual ~Thread(); void start(); - void quit(int code = 0); + void quit(void *code = 0); private: Function m_action; - int m_tid { -1 }; + pthread_t m_tid; String m_thread_name; };