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 spec/concurrent/atomic/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ def subject.simulate_spurious_wake_up
expect(latch.wait(0.1)).to be false
end

it 'should resist to spurious wake ups with timeout' do
it 'should resist spurious wake ups with timeout', buggy: true do
latch = CountDownLatch.new(1)
t = Thread.new{ subject.wait(0.3); latch.count_down }
t = Thread.new{ subject.wait(0.5); latch.count_down }
t.join(0.1)

subject.simulate_spurious_wake_up
Expand Down
2 changes: 1 addition & 1 deletion spec/concurrent/exchanger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
t1.kill
end

it 'allows multiple firsts to cancel if necessary' do
it 'allows multiple firsts to cancel if necessary', buggy: true do
first_value = nil
second_value = nil
cancels = 3
Expand Down
26 changes: 16 additions & 10 deletions spec/concurrent/executor/thread_pool_executor_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@

context ':caller_runs' do

subject do
let(:executor) do
described_class.new(
min_threads: 1,
max_threads: 1,
Expand All @@ -475,14 +475,20 @@
)
end

after(:each) do
# need to replicate this w/i scope otherwise rspec may complain
executor.kill
executor.wait_for_termination(0.1)
end

specify '#post does not create any new threads when the queue is at capacity' do
trigger = Concurrent::Event.new
initial = Thread.list.length

# Post several tasks to the executor. Has to be a new thread,
# because it will start blocking once the queue fills up.
Thread.new do
5.times{ subject.post{ trigger.wait } }
5.times{ executor.post{ trigger.wait } }
end

expect(Thread.list.length).to be < initial + 1 + 5
Expand All @@ -494,32 +500,32 @@
specify '#<< executes the task on the current thread when the queue is at capacity' do
trigger = Concurrent::Event.new
latch = Concurrent::CountDownLatch.new(5)
subject.post{ trigger.wait }
5.times{|i| subject << proc { latch.count_down } }
executor.post{ trigger.wait }
5.times{|i| executor << proc { latch.count_down } }
latch.wait(0.1)
trigger.set
end

specify '#post executes the task on the current thread when the queue is at capacity' do
trigger = Concurrent::Event.new
latch = Concurrent::CountDownLatch.new(5)
subject.post{ trigger.wait }
5.times{|i| subject.post{ latch.count_down } }
executor.post{ trigger.wait }
5.times{|i| executor.post{ latch.count_down } }
latch.wait(0.1)
trigger.set
end

specify '#post executes the task on the current thread when the executor is shutting down' do
latch = Concurrent::CountDownLatch.new(1)
subject.shutdown
subject.post{ latch.count_down }
executor.shutdown
executor.post{ latch.count_down }
latch.wait(0.1)
end

specify '#<< executes the task on the current thread when the executor is shutting down' do
latch = Concurrent::CountDownLatch.new(1)
subject.shutdown
subject << proc { latch.count_down }
executor.shutdown
executor << proc { latch.count_down }
latch.wait(0.1)
end
end
Expand Down
29 changes: 16 additions & 13 deletions spec/concurrent/executor/thread_pool_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,23 @@
expect(subject.completed_task_count).to eq 0
end

it 'returns the approximate number of tasks that have been completed thus far' do
5.times{ subject.post{ raise StandardError } }
5.times{ subject.post{ nil } }
subject.post { latch.count_down }
latch.wait(1)
expect(subject.completed_task_count).to be > 1
end
unless Concurrent.on_jruby?

it 'returns the approximate number of tasks that have been completed thus far' do
5.times{ subject.post{ raise StandardError } }
5.times{ subject.post{ nil } }
subject.post { latch.count_down }
latch.wait(1)
expect(subject.completed_task_count).to be > 1
end

it 'returns the approximate number of tasks that were completed' do
5.times{ subject.post{ raise StandardError } }
5.times{ subject.post{ nil } }
subject.shutdown
subject.wait_for_termination(1)
expect(subject.completed_task_count).to be > 1
it 'returns the approximate number of tasks that were completed' do
5.times{ subject.post{ raise StandardError } }
5.times{ subject.post{ nil } }
subject.shutdown
subject.wait_for_termination(1)
expect(subject.completed_task_count).to be > 1
end
end
end

Expand Down