提交 aebbd4bb 编写于 作者: J Jeremy Kemper

No need to defensively work jobs in another thread

上级 96e713b0
...@@ -110,7 +110,7 @@ def shutdown ...@@ -110,7 +110,7 @@ def shutdown
end end
def drain def drain
Thread.new { run(@queue.pop) until @queue.empty? }.join run(@queue.pop) until @queue.empty?
end end
def consume def consume
......
...@@ -97,6 +97,6 @@ def test_drain ...@@ -97,6 +97,6 @@ def test_drain
assert @queue.empty? assert @queue.empty?
assert job.ran?, "The job runs synchronously when the queue is drained" assert job.ran?, "The job runs synchronously when the queue is drained"
assert_not_equal job.thread_id, Thread.current.object_id assert_equal job.thread_id, Thread.current.object_id
end end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册