class method
Thread::SizedQueue.new
[Elem = untyped] (::Integer max) -> ::Thread::SizedQueue[Elem]
new(max)
thread_sync.c
View on GitHub ↗
static VALUE
rb_szqueue_initialize(VALUE self, VALUE vmax)
{
long max;
struct rb_szqueue *sq = szqueue_ptr(self);
max = NUM2LONG(vmax);
if (max <= 0) {
rb_raise(rb_eArgError, "queue size must be positive");
}
RB_OBJ_WRITE(self, szqueue_list(sq), ary_buf_new());
ccan_list_head_init(szqueue_waitq(sq));
ccan_list_head_init(szqueue_pushq(sq));
sq->max = max;
return self;
}
Creates a fixed-length queue with a maximum size of max.