Skip to content

Bring drifted copies back in step, and fix comments that no longer match the code - #132

Merged
HalRiveria merged 5 commits into
mainfrom
refactor/drift-and-comments
Dec 3, 2026
Merged

HalRiveria merged 5 commits into
mainfrom
refactor/drift-and-comments

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong

Copies of the same logic had drifted apart, and some comments no longer matched the code:

  • Invoke-PkRunspaceBatch's -MaxConcurrent error didn't say what it got, as the other engines' errors do.
  • Comments on the four job keys Start-PkProcessCore returns said it builds them in two places and that they're copied in four. It's one place, copied in three.
  • The comments on the shared -StreamTimeoutMs default of 15000 named three of the four places that use it.
  • PkState's note pointed at "the note at the top of this file", which the C# file doesn't have since the C# moved to Source/.
  • The TypesVersion note said to bump it on any change to "this file". It's once per release, for any of the kit's C#.
  • KillTree's notes said "the caller then uses taskkill"; only Stop-PkProcessTree does.
  • One comment cited a review finding, so it didn't stand on its own.
  • One comment had a typo ("Invoke-PkRunspaceBatch' main loop").
  • Two help lines were wrapped mid-sentence, and Invoke-PkProcessWithTimeout's cleanup had two back-to-back comment blocks.
  • Stop-PkFailedStartTree had a try/catch around reading Process.Id, which can't throw: a disposed Process reads $null.

What changed

  • The -MaxConcurrent error now says what it got.
  • The comments above are corrected, and each copy now names the others.
  • The needless try/catch is gone.

The C# changes are comments only, copied into ParallelKit.ps1 with Build/Update-ParallelKitCSharp.ps1. No other behavior changes.

How it was tested

…t leaves something running

Every kill path for one program now goes through Stop-PkProgramTree: the time-limit kill, -KillTreeOnExit, Invoke-PkProcessWithTimeout's kills and a failed start's rollback. The two rollbacks (a reader that can't start, a -JobStarter that throws after starting its program) share Stop-PkFailedStartTree, and when Windows won't end the program's tree job, or an exited program has none, the start's failure now says what it started may still be running instead of that it was stopped. Invoke-PkProcessWithTimeout's cleanup uses the force-stop's steps.
Invoke-PkRunspaceBatch's -MaxConcurrent error now says what it got, as the other engines' do; every -StreamTimeoutMs default of 15000 names the other three; and the comments on Start-PkProcessCore's four job keys say they're copied in three places, not four.
…wo help lines

The note on Start-PkProcessCore's result no longer says it builds it in two places; PkState's note says why it's static instead of pointing at a note the C# file doesn't have; the TypesVersion note says once per release; KillTree's notes name Stop-PkProcessTree as what falls back to taskkill; Invoke-PkProcessWithTimeout's cleanup has one comment instead of two; and a comment that cited a review finding stands on its own.
@HalRiveria
HalRiveria merged commit 0cc76cf into main Dec 3, 2026
3 checks passed
@HalRiveria
HalRiveria deleted the refactor/drift-and-comments branch December 3, 2026 18:49
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