Skip to content

Commit c2e8c31

Browse files
committed
Do not use timeout
1 parent ab5cdf2 commit c2e8c31

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

spec/concurrent/synchronization_spec.rb

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,30 @@ def ns_initialize
141141
end
142142

143143
it 'releases the lock on the current object' do
144-
expect { Timeout.timeout(3) do
145-
t = in_thread { subject.wait }
144+
t1 = in_thread do
145+
t2 = in_thread { subject.wait }
146146
sleep 0.1
147147
# TODO (pitr-ch 15-Oct-2016): https://travis-ci.org/pitr-ch/concurrent-ruby/jobs/167933569
148-
expect(t.status).to eq 'sleep'
148+
status = t2.status
149149
subject.synchronize {} # we will deadlock here if #wait doesn't release lock
150-
end }.not_to raise_error
150+
end
151+
152+
join_with t1
153+
expect(t1.value).to eq 'sleep'
151154
end
152155

153156
it 'can be called from within a #synchronize block' do
154-
expect { Timeout.timeout(3) do
157+
t1 = in_thread do
155158
# #wait should release lock, even if it was already held on entry
156-
t = in_thread { subject.synchronize { subject.wait } }
159+
t2 = in_thread { subject.synchronize { subject.wait } }
157160
sleep 0.1
158-
expect(t.status).to eq 'sleep'
161+
status = t2.status
159162
subject.synchronize {} # we will deadlock here if lock wasn't released
160-
end }.not_to raise_error
163+
status
164+
end
165+
166+
join_with t1
167+
expect(t1.value).to eq 'sleep'
161168
end
162169
end
163170

0 commit comments

Comments
 (0)