File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ module Concurrent
42
42
end
43
43
44
44
context 'concurrency' do
45
- it do
45
+ it '#add and #delete' do
46
46
( 1 ..Concurrent ::ThreadSafe ::Test ::THREADS ) . map do |i |
47
47
in_thread do
48
48
1000 . times do
@@ -55,6 +55,36 @@ module Concurrent
55
55
end . map ( &:join )
56
56
expect ( set ) . to be_empty
57
57
end
58
+
59
+ it '#each' do
60
+ threads = [ ]
61
+ ( "a" .."z" ) . inject ( set , &:<< ) # setup a non-empty set
62
+
63
+ threads << in_thread do
64
+ 2000 . times do
65
+ size = nil
66
+ set . each do |member |
67
+ if size . nil?
68
+ size = set . length
69
+ else
70
+ expect ( set . length ) . to eq ( size )
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ threads += ( 1 ..19 ) . map do |i |
77
+ in_thread do
78
+ v = i * 1000
79
+ 10 . times do
80
+ 200 . times { |j | set << ( v +j ) }
81
+ 200 . times { |j | set . delete ( v +j ) }
82
+ end
83
+ end
84
+ end
85
+
86
+ threads . map ( &:join )
87
+ end
58
88
end
59
89
end
60
90
end
You can’t perform that action at this time.
0 commit comments