function testUpdate($reactor) { $dispatcher = new Dispatcher($reactor); $promise = $dispatcher->execute(new TestStreamStackable()); $promise->watch(function ($update) { echo "{$update}\n"; }); $promise->when(function ($error, $result) use($reactor) { assert($result === null); $reactor->stop(); }); }
public function testNewWorkerIncludes() { (new NativeReactor())->run(function ($reactor) { $dispatcher = new Dispatcher($reactor); $dispatcher->addStartTask(new TestAutoloaderStackable()); $dispatcher->setOption(Dispatcher::OPT_POOL_SIZE_MAX, 1); $promise = $dispatcher->call('Amp\\Thread\\Test\\AutoloadableClassFixture::test'); $promise->when(function ($error, $result) use($reactor) { $this->assertEquals(42, $result); $reactor->stop(); }); }); }