macOS: add ThreadSupport (no-op suspend/resume)#3036
Open
tomjn wants to merge 1 commit into
Open
Conversation
aa26c53 to
c5a6ff0
Compare
sprunk
reviewed
Jun 20, 2026
The Linux ThreadSupport suspends/resumes threads via a SIGUSR1 handler plus getcontext()/ucontext_t, which has no portable macOS equivalent. Add a macOS ThreadSupport.cpp providing no-op Suspend()/Resume() and the thread setup/start plumbing, and wire it into the Mac threading sources. Performance-core preference is handled separately as a QoS hint in Threading::SetAffinity (the main and worker threads reach it via SetAffinityHelper), so it is not duplicated here. Mac-only: the file is in sources_engine_System_Threading_Mac, so Windows and Linux builds are unaffected.
c5a6ff0 to
9d51525
Compare
sprunk
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
rts/System/Platform/Mac/ThreadSupport.cppand wires it into the Mac threading sources.The Linux
ThreadSupportsuspends/resumes threads via aSIGUSR1signal handler plusgetcontext()/ucontext_t— none of which has a portable macOS equivalent. This macOS version provides:Suspend()/Resume()as no-ops (macOS has no signal-based thread suspend).ThreadStart/SetupCurrentThreadControls— the thread setup/start plumbing (create theThreadControls, recordpthread_self(), signal initialization, run the task).QoS / performance cores
Deliberately not handled here. Performance-core preference is a QoS hint applied in
Threading::SetAffinity()(see the macOS affinity change), which the main and worker threads already reach viaSetAffinityHelper()(ThreadPool.cpp). Keeping it in one place avoids applying the QoS class twice.CMake
On
APPLE,sources_engine_System_Platform_Macpreviously pulled inPlatform/Linux/ThreadSupport.cpp— which doesn't compile on macOS (it usesSYS_gettid/sigaction/ucontext). This swaps that out: the newMac/ThreadSupport.cppis added tosources_engine_System_Threading_Mac, and the Linux file is dropped fromsources_engine_System_Platform_Mac(otherwise both would compile on APPLE → duplicate symbols).Cross-platform safety
Mac-only: the only lists touched are the
*_Macones, used solely underif(APPLE). Windows and Linux builds are byte-for-byte unaffected.Adapted from the macOS bring-up (#2991) as a standalone, reviewable piece (minus the QoS, which lives with the affinity change).