Skip to content

Commit

Permalink
Merge branch 'billdueber-isolated_threadpool_fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdantonio committed Jun 10, 2014
2 parents fe39e28 + 636ece4 commit 49417cb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -140,6 +140,7 @@ task.value #=> 25.96
* [Ravil Bayramgalin](https://github.com/brainopia)
* [Larry Lv](https://github.com/larrylv)
* [Giuseppe Capizzi](https://github.com/gcapizzi)
* [Bill Dueber](https://github.com/billdueber)
* [Brian Shirai](https://github.com/brixen)
* [Chip Miller](https://github.com/chip-miller)
* [Jamie Hodge](https://github.com/jamiehodge)
Expand Down
1 change: 0 additions & 1 deletion lib/concurrent/executor/ruby_thread_pool_executor.rb
Expand Up @@ -172,7 +172,6 @@ def execute(*args, &task)

# @!visibility private
def shutdown_execution
@queue.clear
if @pool.empty?
stopped_event.set
else
Expand Down
7 changes: 6 additions & 1 deletion lib/concurrent/executor/timer_set.rb
Expand Up @@ -61,7 +61,12 @@ def post(intended_time, *args, &task)

end

alias_method :kill, :shutdown
# For a timer, #kill is like an orderly shutdown, except we need to manually
# (and destructively) clear the queue first
def kill
@queue.clear
shutdown
end

# Calculate an Epoch time with milliseconds at which to execute a
# task. If the given time is a `Time` object it will be converted
Expand Down
30 changes: 30 additions & 0 deletions spec/concurrent/executor/thread_pool_shared.rb
Expand Up @@ -100,6 +100,36 @@
end
end

context '#shutdown followed by #wait_for_termination' do
it "allows in-progress tasks to complete" do
@expected = false
subject.post{ sleep 0.1; @expected = true }
subject.shutdown
subject.wait_for_termination(1)
@expected.should be_true
end

it 'allows pending tasks to complete' do
@expected = false
subject.post{ sleep(0.1) }
subject.post{ sleep(0.1); @expected = true }
subject.shutdown
subject.wait_for_termination(1)
@expected.should be_true
end

it "stops accepting/running new tasks" do
@expected = :start
subject.post{ sleep(0.1) }
subject.post{ sleep(0.1); @expected = :should_be_run }
subject.shutdown
subject.post{ @expected = :should_not_be_run }
subject.wait_for_termination(1)
@expected.should == :should_be_run
end
end


context '#kill' do

it 'stops accepting new tasks' do
Expand Down

4 comments on commit 49417cb

@billdueber
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we'll see a point release soon? I've got a couple applications where I'd like to be able to use the new thread code.

@jdantonio
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. As soon as @pitr-ch merges #100 we'll release 0.6.1. Hopefully within the next couple of days.

@pitr-ch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to fix one last issue with documentation #110 then I'll merge #100 it should happen tomorrow evening.

@jdantonio
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@billdueber This fix is now live in the 0.6.1 release. I'll start looking into Issue #106 as soon as we merge PR #109.

Please sign in to comment.