src/Loop.php
public static function execute(callable $callback, Driver $driver = null)
    {
        $previousDriver = self::$driver;

        self::$driver = $driver ?: self::createDriver();
        self::$level++;

        try {
            self::$driver->defer($callback);
            self::$driver->run();
        } finally {
            self::$driver = $previousDriver;
            self::$level--;
        }
    }
public static function execute(callable $callback, Driver $driver = null)
    {
        $previousDriver = self::$driver;

        self::$driver = $driver ?: self::createDriver();
        self::$level++;

        try {
            self::$driver->defer($callback);
            self::$driver->run();
        } finally {
            self::$driver = $previousDriver;
            self::$level--;
        }
    }
public static function execute ( callable $ callback , Driver $ driver = null ) { $ previousDriver = self :: $ driver ; self :: $ driver = $ driver ? : self :: createDriver ( ) ; self :: $ level ++ ; try { self :: $ driver -> defer ( $ callback ) ; self :: $ driver -> run ( ) ; } finally { self :: $ driver = $ previousDriver ; self :: $ level -- ; } }
Execute a callback within the scope of an event loop driver.

The loop MUST continue to run until it is either stopped explicitly, no referenced watchers exist anymore, or an
exception is thrown that cannot be handled. Exceptions that cannot be handled are exceptions thrown from an
error handler or exceptions that would be passed to an error handler but none exists to handle them.

@param callable $callback The callback to execute.
@param Driver $driver The event loop driver. If `null`, a new one is created from the set factory.

@return void

@see \AsyncInterop\Loop::setFactory()
Execute a callback within the scope of an event loop driver .