/** * @test */ public function execute() { $task = new Task(function ($arg) { return 'foo' . $arg; }, 'bar', null); $this->assertInstanceOf('\\Ackintosh\\Snidel\\Result\\Result', $task->execute()); }
/** * @param string $serializedTask * @return \Ackintosh\Snidel\TaskInterface */ public static function unserialize($serializedTask) { $task = unserialize($serializedTask); if (self::isClosure($callable = $task->getCallable())) { $task = new Task($callable->getClosure(), $task->getArgs(), $task->getTag()); } return $task; }
/** * @return void * @throws \RuntimeException */ public function run() { try { $result = $this->task->execute(); } catch (\RuntimeException $e) { throw $e; } $result->setFork($this->fork); try { $this->resultQueue->enqueue($result); } catch (\RuntimeException $e) { throw $e; } }