ThreadPool concurrency refactoring (#2220)#3
ThreadPool concurrency refactoring (#2220)#3MitchLewis930 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>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨No code suggestions found for the PR. |
User description
PR_053
PR Type
Enhancement, Bug fix
Description
Wait for threads to enter waiting loop on ThreadPool startup
Simplify spawn_thread inner threadpool loop and remove continue flag
Fix concurrency bugs in trim and shutdown logic
Refactor tests with MutexPool wrapper for better stability
Add with_mutex helper to handle nested synchronization
Diagram Walkthrough
File Walkthrough
thread_pool.rb
Refactor ThreadPool concurrency and synchronization logiclib/puma/thread_pool.rb
@not_full.wait(@mutex)spawn_threadby removingcontinueflag and handling threadexit directly
@spawned, delete from@workers) intotrim logic
with_mutexhelper method to handle nested synchronization safelytrimlogic to calculate free threads as@waiting - @todo.sizeshutdownto set@trim_requested = @spawnedfor proper cleanuptest_thread_pool.rb
Refactor tests with MutexPool for better stabilitytest/test_thread_pool.rb
MutexPoolwrapper class to synchronize work execution fordeterministic tests
management
@not_full.waitin MutexPooltest_waiting_on_startupto verify threads wait on initializationtest_thread_nameas separate test for thread namingskip_ondirectives andpausecalls by using MutexPoolsynchronization
History.md
Update changelog with ThreadPool improvementsHistory.md
Rubies