join() public method

Causes the calling context to wait for the referenced Thread to finish executing
public join ( ) : boolean
return boolean A boolean indication of state
Ejemplo n.º 1
0
 /**
  * @expectedException RuntimeException
  */
 public function testThreadAlreadyJoined()
 {
     $thread = new Thread();
     $this->assertEquals($thread->start(), true);
     $this->assertEquals($thread->join(), true);
     $this->assertEquals($thread->join(), false);
 }
Ejemplo n.º 2
0
 /**
  * @expectedException RuntimeException
  */
 public function testThreadAlreadyJoined()
 {
     $thread = new Thread();
     $this->assertTrue($thread->start());
     $this->assertTrue($thread->join());
     $this->assertFalse($thread->join());
 }
Ejemplo n.º 3
0
 public function handle(\Thread $thread)
 {
     $thread->start();
     echo "Start thread with ID {$thread->getCurrentThreadId()}\n";
     return Observable::create(function (ObserverInterface $observer) use($thread) {
         while ($thread->isRunning()) {
             $this->loop->tick();
         }
         try {
             echo "Thread finished\n";
             $thread->join();
             $observer->onNext(new Event('/thread/ok', $thread));
             $observer->onCompleted();
         } catch (\Exception $e) {
             echo "Thread error\n";
             $observer->onError($e);
         }
         unset($thread);
     });
 }