Skip to content

Commit

Permalink
Merge pull request #2036 from composerinteralia/threadpool-todos
Browse files Browse the repository at this point in the history
Address thread pool test TODOs [changelog skip]
  • Loading branch information
nateberkopec committed Oct 17, 2019
2 parents 6ad254f + b4009d1 commit a512065
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/test_thread_pool.rb
Expand Up @@ -223,27 +223,32 @@ def test_reap_only_dead_threads
def test_auto_reap_dead_threads
pool = new_pool(2,2) { Thread.current.kill }

pool.auto_reap! 0.1

pause

assert_equal 2, pool.spawned

# TODO: is there a point to these two lines?
pool << 1
pool << 2

pool.auto_reap! 0.1

pause

assert_equal 0, pool.spawned
end

def test_force_shutdown_immediately
finish = false
rescued = false

pool = new_pool(0, 1) do |work|
begin
@work_mutex.synchronize do
@work_done.signal
end
sleep 10 # TODO: do something here other than sleep
Thread.pass until finish
rescue Puma::ThreadPool::ForceShutdown
rescued = true
end
end

Expand All @@ -252,7 +257,9 @@ def test_force_shutdown_immediately
@work_mutex.synchronize do
@work_done.wait(@work_mutex, 5)
pool.shutdown(0)
finish = true
assert_equal 0, pool.spawned
assert rescued
end
end
end

0 comments on commit a512065

Please sign in to comment.