public function setMax(string $key, int $max_size = -1): int
    {
        $is_exist = !$this->init($key, $max_size);
        if ($is_exist && $this->resource_map[$key] instanceof Channel) {
            $current_max = $this->status_map[$key]['max'];
            $this->status_map[$key]['max'] = $max_size;
            if ($max_size > $current_max || $max_size < 0) { // expend or unlimited
                if ($max_size < 0) { // chan to queue
                    $new_pool = new SplQueue();
                } else {
                    $new_pool = new Channel($max_size);
                }
                $old_chan = $this->resource_map[$key];
                while (!$old_chan->isEmpty()) {
                    $new_pool->push($old_chan->pop());
                }
                $old_chan->close();
                return 1; // expend
            } elseif ($max_size < $this->status_map[$key]['max']) {
                return -1; // reduce
            }
        }
        return 0; // do nothing
    }
public function setMax(string $key, int $max_size = -1): int
    {
        $is_exist = !$this->init($key, $max_size);
        if ($is_exist && $this->resource_map[$key] instanceof Channel) {
            $current_max = $this->status_map[$key]['max'];
            $this->status_map[$key]['max'] = $max_size;
            if ($max_size > $current_max || $max_size < 0) { // expend or unlimited
                if ($max_size < 0) { // chan to queue
                    $new_pool = new SplQueue();
                } else {
                    $new_pool = new Channel($max_size);
                }
                $old_chan = $this->resource_map[$key];
                while (!$old_chan->isEmpty()) {
                    $new_pool->push($old_chan->pop());
                }
                $old_chan->close();
                return 1; // expend
            } elseif ($max_size < $this->status_map[$key]['max']) {
                return -1; // reduce
            }
        }
        return 0; // do nothing
    }
public function setMax ( string $ key , int $ max_size = - 1 ) : int { $ is_exist = ! $ this -> init ( $ key , $ max_size ) ; if ( $ is_exist && $ this -> resource_map [ $ key ] instanceof Channel ) { $ current_max = $ this -> status_map [ $ key ] [ 'max' ] ; $ this -> status_map [ $ key ] [ 'max' ] = $ max_size ; if ( $ max_size > $ current_max || $ max_size < 0 ) { // expend or unlimited if ( $ max_size < 0 ) { // chan to queue $ new_pool = new SplQueue ( ) ; } else { $ new_pool = new Channel ( $ max_size ) ; } $ old_chan = $ this -> resource_map [ $ key ] ; while ( ! $ old_chan -> isEmpty ( ) ) { $ new_pool -> push ( $ old_chan -> pop ( ) ) ; } $ old_chan -> close ( ) ; return 1 ; // expend } elseif ( $ max_size < $ this -> status_map [ $ key ] [ 'max' ] ) { return - 1 ; // reduce } } return 0 ; // do nothing }
expend will create the new chan

@param string $key
@param int $max_size
@return int do what
expend will create the new chan