Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Jul 2, 2018
2 parents d67bb18 + 9d21b20 commit c12fd63
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions src/Listener/WorkerInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Imi\Listener;

use Imi\Main\Helper;
use Imi\Util\Coroutine;
use Imi\Bean\Annotation;
use Imi\Pool\PoolConfig;
use Imi\Event\EventParam;
Expand All @@ -28,28 +29,46 @@ public function handle(EventParam $e)
Annotation::getInstance()->init($appMains);

// 初始化
foreach($appMains as $main)
if(Coroutine::isIn())
{
// 协程通道队列初始化
CoroutineChannelManager::setNames($main->getConfig()['coroutineChannels'] ?? []);

// 异步池子初始化
$pools = $main->getConfig()['pools'] ?? [];
foreach($pools as $name => $pool)
foreach($appMains as $main)
{
if(isset($pool['async']))
// 协程通道队列初始化
CoroutineChannelManager::setNames($main->getConfig()['coroutineChannels'] ?? []);

// 异步池子初始化
$pools = $main->getConfig()['pools'] ?? [];
foreach($pools as $name => $pool)
{
$pool = $pool['async'];
PoolManager::addName($name, $pool['pool']['class'], new PoolConfig($pool['pool']['config']), $pool['resource']);
if(isset($pool['async']))
{
$pool = $pool['async'];
PoolManager::addName($name, $pool['pool']['class'], new PoolConfig($pool['pool']['config']), $pool['resource']);
}
}
}

// 缓存初始化
$caches = $main->getConfig()['caches'] ?? [];
foreach($caches as $name => $cache)
}
else
{
foreach($appMains as $main)
{
CacheManager::addName($name, $cache['handlerClass'], $cache['option']);
// 同步池子初始化
$pools = $main->getConfig()['pools'] ?? [];
foreach($pools as $name => $pool)
{
if(isset($pool['sync']))
{
$pool = $pool['sync'];
PoolManager::addName($name, $pool['pool']['class'], new PoolConfig($pool['pool']['config']), $pool['resource']);
}
}
}
}
// 缓存初始化
$caches = $main->getConfig()['caches'] ?? [];
foreach($caches as $name => $cache)
{
CacheManager::addName($name, $cache['handlerClass'], $cache['option']);
}
}
}

0 comments on commit c12fd63

Please sign in to comment.