1 //===-- HostThreadPosix.cpp -------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/Core/Error.h" 11 #include "lldb/Host/posix/HostThreadPosix.h" 12 13 #include <errno.h> 14 #include <pthread.h> 15 16 using namespace lldb; 17 using namespace lldb_private; 18 19 HostThreadPosix::HostThreadPosix() 20 { 21 } 22 23 HostThreadPosix::HostThreadPosix(lldb::thread_t thread) 24 : HostNativeThreadBase(thread) 25 { 26 } 27 28 HostThreadPosix::~HostThreadPosix() 29 { 30 } 31 32 Error 33 HostThreadPosix::Join(lldb::thread_result_t *result) 34 { 35 Error error; 36 if (IsJoinable()) 37 { 38 lldb::thread_result_t thread_result; 39 int err = ::pthread_join(m_thread, &thread_result); 40 error.SetError(err, lldb::eErrorTypePOSIX); 41 } 42 else 43 error.SetError(EINVAL, eErrorTypePOSIX); 44 45 Reset(); 46 return error; 47 } 48 49 Error 50 HostThreadPosix::Cancel() 51 { 52 Error error; 53 int err = ::pthread_cancel(m_thread); 54 error.SetError(err, eErrorTypePOSIX); 55 56 return error; 57 } 58 59 Error 60 HostThreadPosix::Detach() 61 { 62 Error error; 63 int err = ::pthread_detach(m_thread); 64 error.SetError(err, eErrorTypePOSIX); 65 Reset(); 66 return error; 67 } 68