获取对象池实例.

@param Pool $pool Pool实例
@param Child $coreBase Core实例（通常为Controller实例）
@return Wrapper|Pool AOP包装的Pool切片实例
187752
public static function getObjectPool(Pool $pool, $coreBase)
    {
        $AOPPool = new Wrapper($pool);

        $AOPPool->registerOnBefore(function ($method, $arguments) use ($coreBase) {
            if ($method === 'push') {
                // 手工处理释放资源
                method_exists($arguments[0], 'destroy') && $arguments[0]->destroy();
                // 自动调用析构方法
                method_exists($arguments[0], '__destruct') && $arguments[0]->__destruct();
                // 自动处理释放资源
                $class = get_class($arguments[0]);
                if (!empty(MI::$__reflections[$class]) && method_exists($arguments[0], 'resetProperties')) {
                    $arguments[0]->resetProperties();
                } else {
                    if (!empty(MI::$__reflections[$class]) && !empty(MI::$__reflections[$class][Macro::DS_PUBLIC])) {
                        foreach (MI::$__reflections[$class][Macro::DS_PUBLIC] as $prop => $val) {
                            $arguments[0]->{$prop} = $val;
                        }
                    }
                }
                $arguments[0]->__isConstruct = false;
            }

            if ($method === 'get') {
                $className = $arguments[0];
                // 支持TaskProxy
                do {
                    if (isset(self::$taskClasses[$className])) {
                        break;
                    }

                    $parents = class_parents($className, true);
                    if (empty($parents)) {
                        self::$taskClasses[$className] = 0;
                        break;
                    }

                    $flag = false;
                    foreach ($parents as $parentClassName) {
                        if ($parentClassName == Task::class) {
                            self::$taskClasses[$className] = 1;
                            $flag = true;
                            break;
                        }
                    }

                    if ($flag) {
                        break;
                    }

                    self::$taskClasses[$className] = 0;
                } while (0);

                if (self::$taskClasses[$className]) {
                    // worker进程
                    if (getInstance()->processType == Macro::PROCESS_WORKER) {
                        array_unshift($arguments, TaskProxy::class);
                    }
                }
            }
            $data = [];
            $data['method'] = $method;
            $data['arguments'] = $arguments;
            return $data;
        });

        $AOPPool->registerOnAfter(function ($method, $arguments, $result) use ($coreBase) {
            //取得对象后放入请求内部bucket
            if ($method === 'get' && is_object($result)) {
                //使用次数+1
                $result->__useCount++;
                $coreBase->objectPoolBuckets[] = $result;
                $result->context = &$coreBase->context;
                $result->parent  = null;//暂时无方案
                $class = get_class($result);
                // 支持TaskProxy
                if ($class == TaskProxy::class) {
                    array_shift($arguments);
                    $result->taskName = $arguments[0];
                }
                // 自动调用构造方法
                if (method_exists($result, '__construct') && $result->__isConstruct == false) {
                    if (!isset($arguments[1])) {
                        $arguments[1] = [];
                    }
                    $result->__isConstruct = true;
                    $result->__construct(...$arguments[1]);
                }
                // 支持自动销毁成员变量
                MI::__supportAutoDestroy($class);
                // 对象资源销毁级别
                $result->__DSLevel = $arguments[2] ?? Macro::DS_PUBLIC;
            }
            $data = [];
            $data['method'] = $method;
            $data['arguments'] = $arguments;
            $data['result'] = $result;
            return $data;
        });

        return $AOPPool;
    }
680281
public function getMysqlPool(string $poolName)
    {
        $activePoolName = $poolName;
        $poolName       = MysqlAsynPool::ASYN_NAME . $poolName;
        if (isset($this->mysqlPools[$poolName])) {
            return $this->mysqlPools[$poolName];
        }

        $pool = getInstance()->getAsynPool($poolName);
        if (!$pool) {
            $pool = new MysqlAsynPool($this->getConfig(), $activePoolName);
            getInstance()->addAsynPool($poolName, $pool, true);
        }

        $this->mysqlPools[$poolName] = AOPFactory::getMysqlPoolCoroutine($pool, $this);
        return $this->mysqlPools[$poolName];
    }
31336
function execute(name, execb) {
    var pool = pools[name];
    if (!pool) {
        execb(null);
        console.error('获取redis连接[ %s ]未找到连接池对象!', name);
        return;
    }
    if (pool.proxy) {
        execb(pool.client, function () {
        });
    } else {
        // 连接池中获取对象
        pool.client.acquire(function (err, client) {
            var release = function () {
                pool.client.release(client);
            };
            if (err) {
                console.error('执行Redis命令时报错: %s', err.stack);
                release();
            } else {
                if (pool.auth_pass) {
                    client.auth(pool.auth_pass, function () {
                        execb(client, release);
                    });
                } else {
                    execb(client, release);
                }
            }
        }, 0);
    }
}
378407
public static ResourcePoolsBuilder newResourcePoolsBuilder(ResourcePools pools) {
    ResourcePoolsBuilder poolsBuilder = new ResourcePoolsBuilder();
    for (ResourceType<?> currentResourceType : pools.getResourceTypeSet()) {
      poolsBuilder = poolsBuilder.with(pools.getPoolForResource(currentResourceType));
    }
    return poolsBuilder;
  }
630607
@Override
    public Object getPool(Collection<Object> pools)
    {
        try
        {
            return Iterables.get(pools, getAndIncrement(pools.size()));
        }
        catch (IndexOutOfBoundsException e)
        {
            return pools.iterator().next();
        }
    }
461200
public function setAttributes(string $queueName, array $attributes=array()) {
        if(!$queueName){
            return $this->error('参数有误');
        }
        try{
            $queue = $this->client->getQueueRef($queueName);
            $queue->setAttribute($this->makeQueueAttributes($attributes));
            return $this->success('设置队列属性成功');
        }catch(MnsException $exception){
            return $this->parseException($exception, '设置队列属性');
        }
    }
950641
public function preparePool($classOrName) {
        $queue = new \SplQueue();

        $this->queues[ $classOrName ] = $queue;
        /* @var $bean PoolAble|PoolTrait */
        $bean = Ioc::beanCreate($classOrName, false);
        $config = $bean->poolConfig();
        $bean->_poolName_ = $classOrName;
        $min = $config[ 'min' ];
        $max = $config[ 'max' ];

        $queue->push($bean);
        for ($i = 1; $i < $min; $i++) {
            $bean = Ioc::beanCreate($classOrName, false);
            $bean->_poolName_ = $classOrName;
            $queue->push($bean);
        }
        if (!$max || $max <= $min) {
            $max = $min + 1;
        }

        $chanel = new Channel($max - $min + 1);
        $this->channels[ $classOrName ] = $chanel;
        $buffers = [];
        for ($i = 0; $i < $max - $min; $i++) {
            $buffer = new PoolBuffer($classOrName);
            $chanel->push($buffer);
            $buffers[] = $buffer;
        }
        $this->buffers[ $classOrName ] = $buffers;
        //定时删除
        $idle = $config[ 'idle' ];
        if (!$idle) {
            $idle = 60;
        }
        $check = $config[ 'check' ];
        if (!$check) {
            $check = 30;
        }

        swoole_timer_tick(1000 * $check, function()use($idle) {
            foreach ($this->buffers as $class => $buffer_array) {
                foreach ($buffer_array as $buffer) {
                    /* @var $buffer PoolBuffer */
                    if ($buffer->is_use) {
                        continue;
                    }
                    $time = time() - $buffer->lastActiveTime;
                    if ($time > $idle) {
                        unset($buffer->bean);
                        $buffer->bean = null;
                    }
                }
            }
        });
    }
659733
@CheckReturnValue
  public static Builder fromPool(Pool pool) {
    return new BuilderImpl(pool.poolShutdown, () -> {
      try {
        return pool.dataSource.getConnection();
      } catch (Exception e) {
        throw new DatabaseException("Unable to obtain a connection from the DataSource", e);
      }
    }, new OptionsDefault(pool.flavor));
  }
82558
public function compileCreate(Blueprint $blueprint, Fluent $command, Connection $connection)
    {
        $sql = parent::compileCreate($blueprint, $command, $connection);
        // 添加注释
        if (isset($blueprint->comment))
        {
            $blueprint->comment = str_replace("'", "\'", $blueprint->comment);
            $sql .= " comment = '".$blueprint->comment."'";
        }
        // 添加自增起始值
        if (isset($blueprint->autoIncrement)) {
            $blueprint->autoIncrement = intval($blueprint->autoIncrement);
            $sql .= " auto_increment = {$blueprint->autoIncrement}";
        }
        return $sql;
    }
127763
public static function createComponents($config,$cache = true)
    {
        if (is_string($config)) {
            $className = $config;
            $config = array();
        } else {
            if (!isset($config['class'])) {
                throw new \Exception("组件必须指定class");
            }
            $className = $config['class'];
            unset($config['class']);
        }
        if ($cache && isset(self::$_objComponents[$className])) {
            $obj = self::$_objComponents[$className];
        } else {
            if ($n = func_num_args() > 1) {
                $args = func_get_args();
                switch ($n) {
                    case 2:
                        $obj = new $className($args[1]);
                        break;
                    case 3:
                        $obj = new $className($args[1], $args[2]);
                        break;
                    case 4:
                        $obj = new $className($args[1], $args[2], $args[2]);
                        break;
                    default:
                        unset($args[0]);
                        $class = new \ReflectionClass($className);
                        $obj = call_user_func_array(array($class, 'newInstance'), $args);
                }
            } else {
                $obj = new $className;
            }
            self::$_objComponents[$className] = $obj;
            foreach ($config as $k => $v) {
                $obj->$k = $v;
            }
            if (method_exists($obj, 'init')) {
                $obj->init();
            }
        }

        return $obj;
    }
1293494
public static function get(CacheItemPoolInterface $pool, array $config)
    {
        if ($config['use_tagging']) {
            $pool = new FixedTaggingCachePool(TaggablePSR6PoolAdapter::makeTaggable($pool), ['session']);
        }

        return new Psr6SessionHandler($pool, $config);
    }
335034
public static Pool createPool(String type, ConnectionManager cm, PoolConfiguration pc)
   {
      if (type == null || type.equals(""))
         return new DefaultPool(cm, pc);

      type = type.toLowerCase(Locale.US);
      
      switch (type)
      {
         case "default":
            return new DefaultPool(cm, pc);
         case "stable":
            return new StablePool(cm, pc);
         default:
         {
            Class<? extends Pool> clz = customPoolTypes.get(type);

            if (clz == null)
               throw new RuntimeException(type + " can not be found");

            try
            {
               Constructor constructor = clz.getConstructor(ConnectionManager.class, PoolConfiguration.class);
               return (Pool)constructor.newInstance(cm, pc);
            }
            catch (Exception e)
            {
               throw new RuntimeException(type + " can not be created", e);
            }
         }
      }
   }
243326
public static function get(CacheItemPoolInterface $pool, array $config, array $tags)
    {
        if ($config['use_tagging']) {
            $pool = new FixedTaggingCachePool(TaggablePSR6PoolAdapter::makeTaggable($pool), $tags);
        }

        if (!empty($config['prefix'])) {
            $pool = new PrefixedCachePool($pool, $config['prefix']);
        }

        return new DoctrineCacheBridge($pool);
    }
234102
public function Execute( $provider, $dataPool )
	{
		if ( CoreFuncs::BooleanValue( $this->getAbstractNode(0)->Execute( $provider, $dataPool ) ) instanceof TrueValue &&
			 CoreFuncs::BooleanValue( $this->getAbstractNode(1)->Execute( $provider, $dataPool ) ) instanceof TrueValue )
			return CoreFuncs::$True;
		return CoreFuncs::$False;
	}
1146571
public static ExecutorService build(PoolType type, ThreadFactory factory) {
        int corePoolSize, maximumPoolSize;
        int keepAliveTime = 10;
        BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
        switch (type) {
            case Singleton:
                corePoolSize = maximumPoolSize = 1;
                break;
            case IO:
                corePoolSize = Runtime.getRuntime().availableProcessors() * 10;
                maximumPoolSize = Runtime.getRuntime().availableProcessors() * 20;
                break;
            case Calc:
                corePoolSize = maximumPoolSize = Runtime.getRuntime().availableProcessors() + 1;
                break;
            default:
                throw new IllegalArgumentException(
                    String.format("内部异常，未知线程池类型[%s]", type.toString()));
        }
        return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime,
            TimeUnit.SECONDS, workQueue, factory, DEFAULT_HANDLER);
    }
1150872
public function mysql($name, Child $parent)
    {
        if (empty($name)) {
            return null;
        }
        if($parent->root == null){
            $parent->root = $parent;
        }
        $root = $parent->root;
        $core_name = MysqlAsynPool::AsynName . ":" .$name;
        if ($root->hasChild($core_name)) {
            return $root->getChild($core_name);
        }
        $mysql_pool = get_instance()->getAsynPool($name);
        if($mysql_pool == null) return null;
        $db = $mysql_pool->installDbBuilder();
        $db->setContext($root->getContext());
        $root->addChild($db);
        return $db;
    }
1352062
public function Execute( $provider, $dataPool )
	{
		/**
		 * @var XPath2NodeIterator $iter
		 */
		$iter = XPath2NodeIterator::Create( $this->getAbstractNode(0)->Execute( $provider, $dataPool ) );
		for ( $k = 1; $k < $this->getCount(); $k++)
		{
			// $iter = new NodeIterator( $this->CreateEnumerator( $dataPool, $this->getAbstractNode( $k ), $iter ) );
			$node = $this->getAbstractNode( $k );
			$iter = new NodeIterator( function() use( $dataPool, $node, $iter ) { return $this->CreateEnumerator( $dataPool, $node, $iter ); } );
		}
		return $iter;
	}