File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -141,23 +141,30 @@ def ns_initialize
141
141
end
142
142
143
143
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 }
146
146
sleep 0.1
147
147
# 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
149
149
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'
151
154
end
152
155
153
156
it 'can be called from within a #synchronize block' do
154
- expect { Timeout . timeout ( 3 ) do
157
+ t1 = in_thread do
155
158
# #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 } }
157
160
sleep 0.1
158
- expect ( t . status ) . to eq 'sleep'
161
+ status = t2 . status
159
162
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'
161
168
end
162
169
end
163
170
You can’t perform that action at this time.
0 commit comments