public function start()
    {
        if (0 !== $this->oid) {
            throw new StatusError('The context has already been started.');
        }

        list($parent, $child) = Stream\pair();

        switch ($pid = pcntl_fork()) {
            case -1: // Failure
                throw new ForkException('Could not fork process!');

            case 0: // Child
                // @codeCoverageIgnoreStart

                // Create a new event loop in the fork.
                Loop\loop($loop = Loop\create(false));

                $channel = new ChannelledStream($pipe = new DuplexPipe($parent));
                fclose($child);

                $coroutine = new Coroutine($this->execute($channel));
                $coroutine->done();

                try {
                    $loop->run();
                    $code = 0;
                } catch (\Throwable $exception) {
                    $code = 1;
                }

                $pipe->close();

                exit($code);

                // @codeCoverageIgnoreEnd

            default: // Parent
                $this->pid = $pid;
                $this->oid = posix_getpid();
                $this->channel = new ChannelledStream($this->pipe = new DuplexPipe($child));
                fclose($parent);
        }
    }
public function start()
    {
        if (0 !== $this->oid) {
            throw new StatusError('The context has already been started.');
        }

        list($parent, $child) = Stream\pair();

        switch ($pid = pcntl_fork()) {
            case -1: // Failure
                throw new ForkException('Could not fork process!');

            case 0: // Child
                // @codeCoverageIgnoreStart

                // Create a new event loop in the fork.
                Loop\loop($loop = Loop\create(false));

                $channel = new ChannelledStream($pipe = new DuplexPipe($parent));
                fclose($child);

                $coroutine = new Coroutine($this->execute($channel));
                $coroutine->done();

                try {
                    $loop->run();
                    $code = 0;
                } catch (\Throwable $exception) {
                    $code = 1;
                }

                $pipe->close();

                exit($code);

                // @codeCoverageIgnoreEnd

            default: // Parent
                $this->pid = $pid;
                $this->oid = posix_getpid();
                $this->channel = new ChannelledStream($this->pipe = new DuplexPipe($child));
                fclose($parent);
        }
    }
public function start ( ) { if ( 0 !== $ this -> oid ) { throw new StatusError ( 'The context has already been started.' ) ; } list ( $ parent , $ child ) = Stream \ pair ( ) ; switch ( $ pid = pcntl_fork ( ) ) { case - 1 : // Failure throw new ForkException ( 'Could not fork process!' ) ; case 0 : // Child // @codeCoverageIgnoreStart // Create a new event loop in the fork. Loop \ loop ( $ loop = Loop \ create ( false ) ) ; $ channel = new ChannelledStream ( $ pipe = new DuplexPipe ( $ parent ) ) ; fclose ( $ child ) ; $ coroutine = new Coroutine ( $ this -> execute ( $ channel ) ) ; $ coroutine -> done ( ) ; try { $ loop -> run ( ) ; $ code = 0 ; } catch ( \ Throwable $ exception ) { $ code = 1 ; } $ pipe -> close ( ) ; exit ( $ code ) ; // @codeCoverageIgnoreEnd default : // Parent $ this -> pid = $ pid ; $ this -> oid = posix_getpid ( ) ; $ this -> channel = new ChannelledStream ( $ this -> pipe = new DuplexPipe ( $ child ) ) ; fclose ( $ parent ) ; } }
Starts the context execution.

@throws \Icicle\Concurrent\Exception\ForkException If forking fails.
@throws \Icicle\Stream\Exception\FailureException If creating a socket pair fails.
Starts the context execution .