Skip to content

Commit 54c1cf5

Browse files
committed
Fixed intermittently failing RubyThreadPoolExecutor spec.
1 parent 3cf1433 commit 54c1cf5

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

spec/concurrent/executor/ruby_thread_pool_executor_spec.rb

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -154,28 +154,16 @@ module Concurrent
154154
Thread.list.length.should < initial + 5
155155
end
156156

157-
specify '#post executes the task on the current thread when the queue is at capacity' do
158-
subject.should_receive(:handle_overflow).with(any_args).at_least(:once)
159-
5.times{ subject.post{ sleep(0.1) } }
160-
end
161-
162-
specify '#post executes the task on the current thread when the queue is at capacity' do
163-
bucket = []
164-
5.times{|i| subject.post{ bucket.push(i) } }
165-
sleep(0.1)
166-
bucket.sort.should eq [0, 1, 2, 3, 4]
167-
end
168-
169157
specify '#<< executes the task on the current thread when the queue is at capacity' do
170158
subject.should_receive(:handle_overflow).with(any_args).at_least(:once)
171159
5.times{ subject << proc { sleep(0.1) } }
172160
end
173161

174162
specify '#post executes the task on the current thread when the queue is at capacity' do
175-
bucket = []
176-
5.times{|i| subject << proc { bucket.push(i) } }
177-
sleep(0.1)
178-
bucket.sort.should eq [0, 1, 2, 3, 4]
163+
latch = Concurrent::CountDownLatch.new(5)
164+
subject.post{ sleep(1) }
165+
5.times{|i| subject.post{ latch.count_down } }
166+
latch.wait(0.1)
179167
end
180168
end
181169
end

0 commit comments

Comments
 (0)