public function run($name, $callback) {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('$callback is not callable');
        }

        // Because, we need to remove exists Instance before fork
        $this->Storage->setup();

        $pid = pcntl_fork();
        if ($pid === -1) {
            return false;
        }
        if ($pid) {
            // main fork
            $this->pids[$name] = $pid;
            return true;
        } else {
            $result = call_user_func($callback);
            $this->Storage->set($this->getKey(), $name, $result);
            exit(0);
        }
    }
public function run($name, $callback) {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('$callback is not callable');
        }

        // Because, we need to remove exists Instance before fork
        $this->Storage->setup();

        $pid = pcntl_fork();
        if ($pid === -1) {
            return false;
        }
        if ($pid) {
            // main fork
            $this->pids[$name] = $pid;
            return true;
        } else {
            $result = call_user_func($callback);
            $this->Storage->set($this->getKey(), $name, $result);
            exit(0);
        }
    }
public function run ( $ name , $ callback ) { if ( ! is_callable ( $ callback ) ) { throw new \ InvalidArgumentException ( '$callback is not callable' ) ; } // Because, we need to remove exists Instance before fork $ this -> Storage -> setup ( ) ; $ pid = pcntl_fork ( ) ; if ( $ pid === - 1 ) { return false ; } if ( $ pid ) { // main fork $ this -> pids [ $ name ] = $ pid ; return true ; } else { $ result = call_user_func ( $ callback ) ; $ this -> Storage -> set ( $ this -> getKey ( ) , $ name , $ result ) ; exit ( 0 ) ; } }
Run a new fork with some name
@param string $name
@param \Closure|string|array $callback
@return bool
Run a new fork with some name