setFactory() 공개 정적인 메소드

Setting a factory is only allowed as long as no loop is currently running. Passing null will reset the default driver and remove the factory. The factory will be invoked if none is passed to Loop::execute. A default driver will be created to support synchronous waits in traditional applications.
public static setFactory ( Interop\Async\Loop\DriverFactory $factory = null )
$factory Interop\Async\Loop\DriverFactory New factory to replace the previous one.
예제 #1
0
 /**
  * @test
  * @expectedException \RuntimeException
  * @expectedExceptionMessage new factory while running isn't allowed
  */
 public function setFactoryFailsIfRunning()
 {
     $driver = new DummyDriver();
     $factory = $this->getMockBuilder(Loop\DriverFactory::class)->getMock();
     $factory->method("create")->willReturn($driver);
     Loop::setFactory($factory);
     Loop::execute(function () use($factory) {
         Loop::setFactory($factory);
     });
 }
예제 #2
0
파일: bootstrap.php 프로젝트: amphp/loop
<?php

namespace Amp\Loop;

use Interop\Async\Loop;
Loop::setFactory(new LoopFactory());