diff --git a/README.md b/README.md index 74b893001..03a1fda1b 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Collection classes that were originally part of the (deprecated) `thread_safe` g * [Array](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Array.html) A thread-safe subclass of Ruby's standard [Array](http://ruby-doc.org/core-2.2.0/Array.html). * [Hash](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Hash.html) A thread-safe subclass of Ruby's standard [Hash](http://ruby-doc.org/core-2.2.0/Hash.html). +* [Set](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Set.html) A thread-safe subclass of Ruby's standard [Set](http://ruby-doc.org/stdlib-2.4.0/libdoc/set/rdoc/Set.html). * [Map](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Map.html) A hash-like object that should have much better performance characteristics, especially under high concurrency, than `Concurrent::Hash`. * [Tuple](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Tuple.html) A fixed size array with volatile (synchronized, thread safe) getters/setters. diff --git a/spec/concurrent/array_spec.rb b/spec/concurrent/array_spec.rb index 6f20c9d8c..5d6c7f72a 100644 --- a/spec/concurrent/array_spec.rb +++ b/spec/concurrent/array_spec.rb @@ -13,6 +13,7 @@ module Concurrent end end end.map(&:join) + expect(ary).to be_empty end describe '#slice' do diff --git a/spec/concurrent/hash_spec.rb b/spec/concurrent/hash_spec.rb index 2e5e1061b..459e0a1ad 100644 --- a/spec/concurrent/hash_spec.rb +++ b/spec/concurrent/hash_spec.rb @@ -7,11 +7,12 @@ module Concurrent Thread.new do 1000.times do |j| hsh[i * 1000 + j] = i - hsh[i * 1000 + j] - hsh.delete(i * 1000 + j) + expect(hsh[i * 1000 + j]).to eq(i) + expect(hsh.delete(i * 1000 + j)).to eq(i) end end end.map(&:join) + expect(hsh).to be_empty end end end diff --git a/spec/concurrent/set_spec.rb b/spec/concurrent/set_spec.rb index 670ca0803..6fe8766b1 100644 --- a/spec/concurrent/set_spec.rb +++ b/spec/concurrent/set_spec.rb @@ -1,18 +1,20 @@ -require 'set' +require 'set' module Concurrent - describe Set do + RSpec.describe Set do let!(:set) { described_class.new } it 'concurrency' do (1..THREADS).map do |i| Thread.new do - 1000.times do |j| - set << i - set.empty? - set.delete(i) - end + 1000.times do + v = i + set << v + expect(set).not_to be_empty + set.delete(v) + end end end.map(&:join) + expect(set).to be_empty end end -end \ No newline at end of file +end