/** * @expectedException RuntimeException */ public function testThreadAlreadyJoined() { $thread = new Thread(); $this->assertEquals($thread->start(), true); $this->assertEquals($thread->join(), true); $this->assertEquals($thread->join(), false); }
/** * @expectedException RuntimeException */ public function testThreadAlreadyJoined() { $thread = new Thread(); $this->assertTrue($thread->start()); $this->assertTrue($thread->join()); $this->assertFalse($thread->join()); }
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); }); }