public function run(Application $application) : void {
        if ($this->engineState !== 'idle') {
            throw new InvalidEngineStateException('Engine::run() MUST NOT be called while already running.');
        }

        Loop::setErrorHandler(function(\Throwable $error) use($application) {
            $application->exceptionHandler($error);
            Loop::defer(function() use($application) {
                yield $this->emitAppCleanupEvent($application);
            });
        });

        Loop::run(function() use($application) {
            $this->engineState = 'running';

            if (!$this->hasPlugin(get_class($application))) {
                $this->registerPlugin($application);
            }

            if (!$this->engineBooted) {
                yield $this->emitEngineBootupEvent();
                $this->engineBooted = true;
            }

            yield $application->execute();
            yield $this->emitAppCleanupEvent($application);
            $this->engineState = 'idle';
        });
    }
public function run(Application $application) : void {
        if ($this->engineState !== 'idle') {
            throw new InvalidEngineStateException('Engine::run() MUST NOT be called while already running.');
        }

        Loop::setErrorHandler(function(\Throwable $error) use($application) {
            $application->exceptionHandler($error);
            Loop::defer(function() use($application) {
                yield $this->emitAppCleanupEvent($application);
            });
        });

        Loop::run(function() use($application) {
            $this->engineState = 'running';

            if (!$this->hasPlugin(get_class($application))) {
                $this->registerPlugin($application);
            }

            if (!$this->engineBooted) {
                yield $this->emitEngineBootupEvent();
                $this->engineBooted = true;
            }

            yield $application->execute();
            yield $this->emitAppCleanupEvent($application);
            $this->engineState = 'idle';
        });
    }
public function run ( Application $ application ) : void { if ( $ this -> engineState !== 'idle' ) { throw new InvalidEngineStateException ( 'Engine::run() MUST NOT be called while already running.' ) ; } Loop :: setErrorHandler ( function ( \ Throwable $ error ) use ( $ application ) { $ application -> exceptionHandler ( $ error ) ; Loop :: defer ( function ( ) use ( $ application ) { yield $ this -> emitAppCleanupEvent ( $ application ) ; } ) ; } ) ; Loop :: run ( function ( ) use ( $ application ) { $ this -> engineState = 'running' ; if ( ! $ this -> hasPlugin ( get_class ( $ application ) ) ) { $ this -> registerPlugin ( $ application ) ; } if ( ! $ this -> engineBooted ) { yield $ this -> emitEngineBootupEvent ( ) ; $ this -> engineBooted = true ; } yield $ application -> execute ( ) ; yield $ this -> emitAppCleanupEvent ( $ application ) ; $ this -> engineState = 'idle' ; } ) ; }
Ensures that the appropriate plugins are booted and then executes the application.

@return void
@throws InvalidEngineStateException
Ensures that the appropriate plugins are booted and then executes the application .