Skip to content

Commit

Permalink
Prefer Task.stop to be more consistent with Reactor.stop
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 8, 2017
1 parent 7605ee8 commit 9baa101
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def run
return @fiber
end

# TODO: Should this be called `stop!` or `stop`. Is it siginificantly diferent from Reactor#stop that shoud be named differently? Perhaps `interrupt`?
def stop!
def stop
if @fiber.alive?
exception = Interrupt.new("Stop right now!")
@fiber.resume(exception)
Expand Down
4 changes: 2 additions & 2 deletions spec/async/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
RSpec.describe Async::Task do
let(:reactor) {Async::Reactor.new}

describe '#stop!' do
describe '#stop' do
it "can be stopped" do
state = nil

Expand All @@ -33,7 +33,7 @@
state = :finished
end

task.stop!
task.stop

expect(state).to be == :started
end
Expand Down

0 comments on commit 9baa101

Please sign in to comment.