Skip to content

Commit 129cf00

Browse files
committed
Increase max waiting time in ReentrantReadWriteLock specs to avoid transients
1 parent 543ef62 commit 129cf00

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

‎spec/concurrent/atomic/reentrant_read_write_lock_spec.rb‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ def wait_up_to(secs, &condition)
242242
in_thread{lock.acquire_read_lock;latch1.count_down;latch2.wait;lock.release_read_lock},
243243
in_thread{latch1.wait;lock.acquire_write_lock;good.value=true}
244244
]
245-
wait_up_to(0.2){threads[3].status == 'sleep'}
245+
wait_up_to(0.5){threads[3].status == 'sleep'}
246246
# The last thread should be waiting to acquire a write lock now...
247247
expect(threads[3].status).toeql"sleep"
248248
expect(threads[3]).not_tohold(lock).for_write
249249
expect(good.value).tobefalse
250250
# Throw latch2 and the 3 readers will wake up and all release their read locks...
251251
latch2.count_down
252-
wait_up_to(0.2){good.value}
252+
wait_up_to(0.5){good.value}
253253
expect(threads[3]).tohold(lock).for_write
254254
expect(good.value).tobetrue
255255
end
@@ -265,7 +265,7 @@ def wait_up_to(secs, &condition)
265265
expect{Timeout.timeout(1){threads[0].join}}.not_toraise_error
266266
expect(threads[0]).tohold(lock).for_write
267267
expect(threads[1]).not_tohold(lock).for_write
268-
wait_up_to(0.2){threads[1].status == 'sleep'}
268+
wait_up_to(0.5){threads[1].status == 'sleep'}
269269
expect(threads[1].status).toeql"sleep"
270270
end
271271

@@ -278,7 +278,7 @@ def wait_up_to(secs, &condition)
278278
expect{Timeout.timeout(1){threads[0].join}}.not_toraise_error
279279
expect(threads[0]).tohold(lock).for_read
280280
expect(threads[1]).not_tohold(lock).for_write
281-
wait_up_to(0.2){threads[1].status == 'sleep'}
281+
wait_up_to(0.5){threads[1].status == 'sleep'}
282282
expect(threads[1].status).toeql"sleep"
283283
end
284284

@@ -341,15 +341,15 @@ def wait_up_to(secs, &condition)
341341
in_thread{latch1.wait;lock.acquire_read_lock;good.update{ |n| n+1}},
342342
in_thread{latch1.wait;lock.acquire_read_lock;good.update{ |n| n+1}}
343343
]
344-
wait_up_to(0.2){threads[3].status == 'sleep'}
344+
wait_up_to(0.5){threads[3].status == 'sleep'}
345345
# The last 3 threads should be waiting to acquire read locks now...
346346
unlessConcurrent.on_jruby?# flaky on JRuby
347347
(1..3).each{ |n| expect(threads[n].status).toeql"sleep"}
348348
end
349349
(1..3).each{ |n| expect(threads[n]).not_tohold(lock).for_read}
350350
# Throw latch2 and the writer will wake up and release its write lock...
351351
latch2.count_down
352-
wait_up_to(0.2){good.value == 3}
352+
wait_up_to(0.5){good.value == 3}
353353
(1..3).each{ |n| expect(threads[n]).tohold(lock).for_read}
354354
end
355355

@@ -360,15 +360,15 @@ def wait_up_to(secs, &condition)
360360
in_thread{lock.acquire_write_lock;latch1.count_down;latch2.wait;lock.release_write_lock},
361361
in_thread{latch1.wait;lock.acquire_write_lock;good.value=true},
362362
]
363-
wait_up_to(0.2){threads[1].status == 'sleep'}
363+
wait_up_to(0.5){threads[1].status == 'sleep'}
364364
# The last thread should be waiting to acquire a write lock now...
365365
unlessConcurrent.on_jruby?# flaky on JRuby
366366
expect(threads[1].status).toeql"sleep"
367367
end
368368
expect(threads[1]).not_tohold(lock).for_write
369369
# Throw latch2 and the writer will wake up and release its write lock...
370370
latch2.count_down
371-
wait_up_to(0.2){good.value}
371+
wait_up_to(0.5){good.value}
372372
expect(threads[1]).tohold(lock).for_write
373373
end
374374
end

0 commit comments

Comments
(0)