[Lldb-commits] [PATCH] D120322: [lldb] Simplify HostThreadMacOSX
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 23 05:26:29 PST 2022
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4568e12219f: [lldb] Simplify HostThreadMacOSX (authored by labath).
Changed prior to commit:
https://reviews.llvm.org/D120322?vs=410518&id=410779#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120322/new/
https://reviews.llvm.org/D120322
Files:
lldb/include/lldb/Host/macosx/HostThreadMacOSX.h
lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm
Index: lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm
===================================================================
--- lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm
@@ -7,62 +7,14 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/macosx/HostThreadMacOSX.h"
-#include "lldb/Host/Host.h"
-
#include <CoreFoundation/CoreFoundation.h>
#include <Foundation/Foundation.h>
-#include <pthread.h>
-
using namespace lldb_private;
-
-static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT;
-static pthread_key_t g_thread_create_key = 0;
-
-namespace {
-class MacOSXDarwinThread {
-public:
- MacOSXDarwinThread() { m_pool = [[NSAutoreleasePool alloc] init]; }
-
- ~MacOSXDarwinThread() {
- if (m_pool) {
- [m_pool drain];
- m_pool = nil;
- }
- }
-
- static void PThreadDestructor(void *v) {
- if (v)
- delete static_cast<MacOSXDarwinThread *>(v);
- ::pthread_setspecific(g_thread_create_key, NULL);
- }
-
-protected:
- NSAutoreleasePool *m_pool = nil;
-
-private:
- MacOSXDarwinThread(const MacOSXDarwinThread &) = delete;
- const MacOSXDarwinThread &operator=(const MacOSXDarwinThread &) = delete;
-};
-} // namespace
-
-static void InitThreadCreated() {
- ::pthread_key_create(&g_thread_create_key,
- MacOSXDarwinThread::PThreadDestructor);
-}
-
-HostThreadMacOSX::HostThreadMacOSX() : HostThreadPosix() {}
-
-HostThreadMacOSX::HostThreadMacOSX(lldb::thread_t thread)
- : HostThreadPosix(thread) {}
-
lldb::thread_result_t
HostThreadMacOSX::ThreadCreateTrampoline(lldb::thread_arg_t arg) {
- ::pthread_once(&g_thread_create_once, InitThreadCreated);
- if (g_thread_create_key) {
- ::pthread_setspecific(g_thread_create_key, new MacOSXDarwinThread());
+ @autoreleasepool {
+ return HostThreadPosix::ThreadCreateTrampoline(arg);
}
-
- return HostThreadPosix::ThreadCreateTrampoline(arg);
}
Index: lldb/include/lldb/Host/macosx/HostThreadMacOSX.h
===================================================================
--- lldb/include/lldb/Host/macosx/HostThreadMacOSX.h
+++ lldb/include/lldb/Host/macosx/HostThreadMacOSX.h
@@ -17,8 +17,7 @@
friend class ThreadLauncher;
public:
- HostThreadMacOSX();
- HostThreadMacOSX(lldb::thread_t thread);
+ using HostThreadPosix::HostThreadPosix;
protected:
static lldb::thread_result_t ThreadCreateTrampoline(lldb::thread_arg_t arg);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120322.410779.patch
Type: text/x-patch
Size: 2494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220223/87e589b7/attachment.bin>
More information about the lldb-commits
mailing list