Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/concurrent/atomic/count_down_latch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MutexCountDownLatch
# @param [Fixnum] count the initial count
#
# @raise [ArgumentError] if `count` is not an integer or is less than zero
def initialize(count)
def initialize(count = 1)
unless count.is_a?(Fixnum) && count >= 0
raise ArgumentError.new('count must be in integer greater than or equal zero')
end
Expand Down Expand Up @@ -75,7 +75,7 @@ def count
class JavaCountDownLatch

# @!macro count_down_latch_method_initialize
def initialize(count)
def initialize(count = 1)
unless count.is_a?(Fixnum) && count >= 0
raise ArgumentError.new('count must be in integer greater than or equal zero')
end
Expand Down
5 changes: 5 additions & 0 deletions spec/concurrent/atomic/count_down_latch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
described_class.new('foo')
}.to raise_error(ArgumentError)
end

it 'defaults the count to 1' do
latch = described_class.new
expect(latch.count).to eq 1
end
end

describe '#count' do
Expand Down