From 85c2e08b87a63f6f4ca80c3771740dec743c53d0 Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Wed, 23 Oct 2024 15:22:20 +0100 Subject: [PATCH] NIOPosix on Darwin: inherit main thread QoS --- Sources/NIOPosix/ThreadPosix.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/NIOPosix/ThreadPosix.swift b/Sources/NIOPosix/ThreadPosix.swift index aacaba5b47..f876c42c8a 100644 --- a/Sources/NIOPosix/ThreadPosix.swift +++ b/Sources/NIOPosix/ThreadPosix.swift @@ -43,7 +43,12 @@ private func sysPthread_create( args: UnsafeMutableRawPointer? ) -> CInt { #if canImport(Darwin) - return pthread_create(handle, nil, destructor, args) + var attr: pthread_attr_t = .init() + pthread_attr_init(&attr) + pthread_attr_set_qos_class_np(&attr, qos_class_main(), 0) + let thread = pthread_create(handle, &attr, destructor, args) + pthread_attr_destroy(&attr) + return thread #else #if canImport(Musl) var handleLinux: OpaquePointer? = nil