max= (SizedQueue)

    /*
     * Document-method: max=
     * call-seq: max=(size)
     *
     * Sets the maximum size of the queue.
     *
     */

    static VALUE
    rb_sized_queue_max_set(VALUE self, VALUE value)
    {
        Queue *queue;
        unsigned long new_capacity;
        unsigned long difference;
        Data_Get_Struct(self, Queue, queue);

        new_capacity = NUM2ULONG(value);

        if (new_capacity < 1) {
            rb_raise(rb_eArgError, "value must be positive");
        }

        lock_mutex(&queue->mutex);
        if (queue->capacity && new_capacity > queue->capacity) {
            difference = new_capacity - queue->capacity;
        } else {
            difference = 0;
        }
        queue->capacity = new_capacity;
        for (; difference > 0; --difference) {
            signal_condvar(&queue->space_available);
        }
        unlock_mutex(&queue->mutex);

        return self;
    }