Automattic\WP\Cron_Control\Lock::check_lock PHP Method

check_lock() public static method

Set a lock and limit how many concurrent jobs are permitted
public static check_lock ( $lock, $limit = null, $timeout = null ) : boolean
$lock string Lock name
$limit int Concurrency limit
$timeout int Timeout in seconds
return boolean
    public static function check_lock($lock, $limit = null, $timeout = null)
    {
        // Timeout, should a process die before its lock is freed
        if (!is_numeric($timeout)) {
            $timeout = LOCK_DEFULT_TIMEOUT_IN_MINUTES * \MINUTE_IN_SECONDS;
        }
        // Check for, and recover from, deadlock
        if (self::get_lock_timestamp($lock) < time() - $timeout) {
            self::reset_lock($lock);
            return true;
        }
        // Default limit for concurrent events
        if (!is_numeric($limit)) {
            $limit = LOCK_DEFAULT_LIMIT;
        }
        // Check if process can run
        if (self::get_lock_value($lock) >= $limit) {
            return false;
        } else {
            wp_cache_incr(self::get_key($lock));
            return true;
        }
    }