Base::until PHP Method

until() public method

Loop until callback returns TRUE (for long polling)
public until ( $func, $args = NULL, $timeout = 60 ) : mixed
$func callback
$args array
$timeout int
return mixed
    function until($func, $args = NULL, $timeout = 60)
    {
        if (!$args) {
            $args = [];
        }
        $time = time();
        $max = ini_get('max_execution_time');
        $limit = max(0, ($max ? min($timeout, $max) : $timeout) - 1);
        $out = '';
        // Turn output buffering on
        ob_start();
        // Not for the weak of heart
        while (!$this->hive['ERROR'] && time() - $time + 1 < $limit && !connection_aborted() && !headers_sent() && (session_status() == PHP_SESSION_ACTIVE || session_start()) && !($out = $this->call($func, $args))) {
            if (!$this->hive['CLI']) {
                session_commit();
            }
            // Hush down
            sleep(1);
        }
        ob_flush();
        flush();
        return $out;
    }