Skip to content

Commit

Permalink
Add link to readme; add few expectations to the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr-ch committed Feb 21, 2018
1 parent 3b7de29 commit ae44a84
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions spec/concurrent/array_spec.rb
Expand Up @@ -13,6 +13,7 @@ module Concurrent
end
end
end.map(&:join)
expect(ary).to be_empty
end

describe '#slice' do
Expand Down
5 changes: 3 additions & 2 deletions spec/concurrent/hash_spec.rb
Expand Up @@ -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
18 changes: 10 additions & 8 deletions 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
end

0 comments on commit ae44a84

Please sign in to comment.