Skip to content

Commit

Permalink
pool: fix shutdown breaking every now and then
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed May 27, 2013
1 parent 96d5133 commit 077003a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/thread/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ def shutdown

# Join on all threads in the pool.
def join
@workers.first.join until @workers.empty?
until @workers.empty?
if worker = @workers.first
worker.join
end
end

self
end
Expand Down Expand Up @@ -304,9 +308,9 @@ def spawn_thread
@waiting += 1
@cond.wait @mutex
@waiting -= 1
end

break !shutdown?
end or break
break if @todo.empty? && shutdown?
end

@todo.shift
Expand Down

0 comments on commit 077003a

Please sign in to comment.