ThreadPool concurrency refactoring (#2220)#3
Open
MitchLewis930 wants to merge 1 commit intopr_053_beforefrom
Open
ThreadPool concurrency refactoring (#2220)#3MitchLewis930 wants to merge 1 commit intopr_053_beforefrom
MitchLewis930 wants to merge 1 commit intopr_053_beforefrom
Conversation
- Wait for threads to enter waiting loop on ThreadPool startup - Simplify #spawn_thread inner threadpool loop - Refactor TestThreadPool to make tests faster and more stable Co-authored-by: Nate Berkopec <nate.berkopec@gmail.com>
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.
PR_053
Note
Medium Risk
Touches core thread-pool synchronization and shutdown/trim behavior, which can impact request handling and termination under load; changes are localized but concurrency-sensitive.
Overview
Refactors
Puma::ThreadPool’s concurrency control by introducingwith_mutex(allowing safe nested locking) and switching key operations (backlog, enqueue, capacity waiting, trim/reap, shutdown) to use it.Adjusts worker lifecycle semantics: startup now waits for worker readiness when creating the minimum threads;
trimonly requests exits when there are truly free threads; andshutdowndrives worker exits by setting@trim_requested = @spawnedand broadcasting, with workers decrementing counters and exiting immediately when trimming.Reworks
test_thread_pool.rbto avoid timing-based races by using aMutexPooltest helper that batches work and waits for completion, adds a dedicated thread-name assertion, and adds a new startupwaitingassertion.History.mdnotes the ThreadPool concurrency fixes/refactor.Written by Cursor Bugbot for commit b16d8cb. This will update automatically on new commits. Configure here.