Skip to content

move process affinity off the UI thread - #53

Merged
JamesLinYJ merged 1 commit into
mainfrom
cursor/affinity-off-ui
Nov 9, 2026
Merged

JamesLinYJ merged 1 commit into
mainfrom
cursor/affinity-off-ui

Conversation

@JamesLinYJ

Copy link
Copy Markdown
Owner

Summary

The Set Affinity dialog stays on the UI thread. After the user confirms, the verified ProcIdentity and the selected per-group masks are queued on the existing process-action SingleFlightWorker (the same worker that already runs End Process, End Process Tree, and Set Priority). No extra window message is posted, and the UI thread does not join the worker.

Before SetProcessAffinityMask or SetProcessDefaultCpuSets, the worker re-opens the target with open_process_for_identity (pid and creation_time_100ns). An unknown or mismatched identity returns without writing a mask. A group or mask that native KAFFINITY cannot express fails explicitly and is not truncated to the low bits. A failure after a CPU-set or thread update is reported with the existing affinity error text and is not treated as success.

Test plan

  • cargo check --target x86_64-pc-windows-msvc --all-targets --locked
  • cargo check --target i686-pc-windows-msvc --all-targets --locked
  • cargo check --target aarch64-pc-windows-msvc --all-targets --locked
  • cargo clippy --target x86_64-pc-windows-msvc --all-targets --locked -- -D warnings
  • Windows test run and UI confirmation (this environment cannot link the MSVC binary or compile real resources)
Open in Web Open in Cursor 

The affinity dialog stays on the UI thread. After confirmation, the
process identity and selected group masks are queued on the existing
process-action worker. That worker re-opens the target with
open_process_for_identity before SetProcessAffinityMask or
SetProcessDefaultCpuSets. An unknown identity, a mask that does not fit
the native KAFFINITY, or a group that cannot be expressed fails without
writing a truncated mask. A later failure is not reported as success.

Co-authored-by: jameslincn <jameslincn@outlook.sg>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T06:56:05.578958Z c06e790 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@JamesLinYJ
JamesLinYJ merged commit 184d373 into main Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants