Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Thread::SizedQueue#max=
(::Integer max) -> void
max=(number)
thread_sync.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/thread_sync.rb, line 293
def max=(vmax)
Primitive.cstmt! %{
rb_len_t max = NUM2LEN(vmax);
if (max <= 0) {
rb_raise(rb_eArgError, "queue size must be positive");
}
rb_len_t diff = 0;
struct rb_szqueue *sq = szqueue_ptr(self);
if (max > sq->max) {
diff = max - sq->max;
}
sq->max = max;
sync_wakeup(szqueue_pushq(sq), diff);
return vmax;
}
end
Sets the maximum size of the queue to the given number.