コード例 #1
0
 public function testCallParallel()
 {
     $this->as->add(function ($as) {
         $this->ccm->register($as, 'srv', 'srv.test:1.1', 'http://localhost:12345/ftn');
     });
     $this->as->run();
     $model_as = new \FutoIn\RI\AsyncSteps();
     $model_as->add(function ($as) {
         $iface = $this->ccm->iface('srv');
         $iface->call($as, 'test', array('ping' => 'PINGPING'));
     }, function ($as, $err) {
         $as->executed = false;
     })->add(function ($as, $rsp) {
         $this->assertEquals('PONGPONG', $rsp->pong);
         $this->assertEquals('PINGPING', $rsp->ping);
         $as->executed = true;
     });
     $asl = array();
     for ($i = 0; $i < 10; ++$i) {
         $asl[] = clone $model_as;
     }
     foreach ($asl as $as) {
         $as->execute();
     }
     \FutoIn\RI\AsyncToolTest::run();
     foreach ($asl as $i => $as) {
         $this->assertTrue($as->executed, "Failed on {$i}");
     }
 }
コード例 #2
0
 public function testModel()
 {
     $model_as = new \FutoIn\RI\AsyncSteps();
     $model_as->model_run = false;
     $model_as->add(function ($as) {
         $as->model_run = true;
         $as->success();
     });
     $as = $this->as;
     $as->copyFrom($model_as);
     $as->add(function ($as) use($model_as) {
         $this->assertTrue($as->model_run);
         $as->model_run = false;
         $as->copyFrom($model_as);
         $as->successStep();
     });
     $as->execute();
     AsyncToolTest::run();
     $this->assertTrue($as->model_run);
 }