Bug #9343 ยป 0001-SizedQueue-max-wakes-up-waiters-properly.patch
| ext/thread/thread.c | ||
|---|---|---|
|
diff = max - GET_SZQUEUE_ULONGMAX(self);
|
||
|
}
|
||
|
RSTRUCT_SET(self, SZQUEUE_MAX, vmax);
|
||
|
while (diff > 0 && !NIL_P(t = rb_ary_shift(GET_QUEUE_QUE(self)))) {
|
||
|
while (diff > 0 && !NIL_P(t = rb_ary_shift(GET_SZQUEUE_WAITERS(self)))) {
|
||
|
rb_thread_wakeup_alive(t);
|
||
|
}
|
||
|
return vmax;
|
||
| test/thread/test_queue.rb | ||
|---|---|---|
|
assert_equal(1, q.max)
|
||
|
assert_raise(ArgumentError) { q.max = -1 }
|
||
|
assert_equal(1, q.max)
|
||
|
before = q.max
|
||
|
q.max.times { q << 1 }
|
||
|
t1 = Thread.new { q << 1 }
|
||
|
sleep 0.01 until t1.stop?
|
||
|
q.max = q.max + 1
|
||
|
assert_equal before + 1, q.max
|
||
|
end
|
||
|
def test_queue_pop_interrupt
|
||