/** * */ public function testEventEmitter_SupportsBigAmountOfEventListeners_ForDifferentEvents() { $emitter = new EventEmitter(); $cnt = 0; for ($i = 0; $i < 10000.0; $i++) { $emitter->on(sprintf("event[%s]", $i), function () use($i, &$cnt) { $cnt = $i; }); } $emitter->emit('event[256]'); $this->assertEquals(256, $cnt); }
/** * */ public function __destruct() { unset($this->model); parent::__destruct(); }
/** * @param string $name * @param ChannelModelInterface $model * @param RouterCompositeInterface $router * @param EncoderInterface $encoder * @param LoopInterface $loop * @throws InstantiationException */ public function __construct($name, ChannelModelInterface $model, RouterCompositeInterface $router, EncoderInterface $encoder, LoopInterface $loop) { parent::__construct($loop); try { $router->getBus('input'); $router->getBus('output'); } catch (Exception $ex) { throw new InstantiationException("Could not construct Kraken\\Channel\\Channel due to Router wrong configuration."); } $this->name = $name; $this->model = $model; $this->router = $router; $this->encoder = $encoder; $this->loop = $loop; $this->handlers = []; $this->seed = GeneratorSupport::genId($this->name); $this->counter = 1000000000.0; $this->reqsHelperTimer = null; $this->repsHelperTimer = null; $this->handledRepsTimeout = 10000.0; $this->registerEvents(); $this->registerPeriodicTimers(); }