public function work(Job $job)
    {
        if (!$this->isFree()) {
            throw new Exceptions\EmployeeNotFreeException();
        }

        $this->workPid = pcntl_fork();

        if ($this->workPid == -1) {
            throw new Exceptions\ForkFailedException();
        }

        $this->workState = self::BUSY;
        $this->job = $job;

        if ($this->workPid == 0) {
            try {
                $job->perform();
                exit(0);
            } catch (\Throwable $exception) {
                Logger::getLogger()->error('Uncaught exception in Emphloyer Job.', [
                    'job_class' => get_class($job),
                    'job_id' => $job->getId(),
                    'exception_code' => $exception->getCode(),
                    'exception_message' => $exception->getMessage(),
                    'exception_stacktrace' => $exception->getTraceAsString(),
                    'exception' => $exception
                ]);
                exit(1);
            }
        }
    }
public function work(Job $job)
    {
        if (!$this->isFree()) {
            throw new Exceptions\EmployeeNotFreeException();
        }

        $this->workPid = pcntl_fork();

        if ($this->workPid == -1) {
            throw new Exceptions\ForkFailedException();
        }

        $this->workState = self::BUSY;
        $this->job = $job;

        if ($this->workPid == 0) {
            try {
                $job->perform();
                exit(0);
            } catch (\Throwable $exception) {
                Logger::getLogger()->error('Uncaught exception in Emphloyer Job.', [
                    'job_class' => get_class($job),
                    'job_id' => $job->getId(),
                    'exception_code' => $exception->getCode(),
                    'exception_message' => $exception->getMessage(),
                    'exception_stacktrace' => $exception->getTraceAsString(),
                    'exception' => $exception
                ]);
                exit(1);
            }
        }
    }
public function work ( Job $ job ) { if ( ! $ this -> isFree ( ) ) { throw new Exceptions \ EmployeeNotFreeException ( ) ; } $ this -> workPid = pcntl_fork ( ) ; if ( $ this -> workPid == - 1 ) { throw new Exceptions \ ForkFailedException ( ) ; } $ this -> workState = self :: BUSY ; $ this -> job = $ job ; if ( $ this -> workPid == 0 ) { try { $ job -> perform ( ) ; exit ( 0 ) ; } catch ( \ Throwable $ exception ) { Logger :: getLogger ( ) -> error ( 'Uncaught exception in Emphloyer Job.' , [ 'job_class' => get_class ( $ job ) , 'job_id' => $ job -> getId ( ) , 'exception_code' => $ exception -> getCode ( ) , 'exception_message' => $ exception -> getMessage ( ) , 'exception_stacktrace' => $ exception -> getTraceAsString ( ) , 'exception' => $ exception ] ) ; exit ( 1 ) ; } } }
Tell the Employee to work on the given job.
@param \Emphloyer\Job $job
Tell the Employee to work on the given job .