__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

namespace core\lock;

use core\progress\base;

/**
 * Lock utilities.
 *
 * @package   core
 * @copyright 2023 onwards Catalyst IT EU {@link https://catalyst-eu.net}
 * @author    Mark Johnson <mark.johnson@catalyst-eu.net>
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class lock_utils {
    /**
     * Start a progress bar and attempt to get a lock, updating the bar until a lock is achieved.
     *
     * This will make multiple attempts at getting the lock using a short timeout set by $progressupdatetime. After
     * each failed attempt, it will update the progress bar and try again, until $timeout is reached.
     *
     * @param lock_factory $lockfactory The factory to use to get the lock
     * @param string $resource The resource key we will try to get a lock on
     * @param base $progress The progress bar
     * @param int $timeout The maximum time in seconds to wait for a lock
     * @param string $message Optional message to display on the progress bar
     * @param int $progressupdatetime The number of seconds to wait for each lock attempt before updating the progress bar.
     * @param int $maxlifetime The maxlifetime to set on the lock, if supported.
     * @return lock|false A lock if successful, or false if the timeout expires.
     * @throws \coding_exception
     */
    public static function wait_for_lock_with_progress(
        lock_factory $lockfactory,
        string $resource,
        \core\progress\base $progress,
        int $timeout,
        string $message = '',
        int $progressupdatetime = 10,
        int $maxlifetime = DAYSECS,
    ) {
        if ($progressupdatetime < 1) {
            throw new \invalid_parameter_exception('Progress bar cannot update more than once per second. ' .
                '$progressupdate time must be at least 1.');
        }
        if ($progressupdatetime > $timeout) {
            throw new \invalid_parameter_exception('$timeout must be greater than $progressupdatetime.');
        }
        $lockattempts = 0;
        $maxattempts = $timeout / $progressupdatetime;
        $lock = false;
        $progress->start_progress($message);
        while (!$lock && $lockattempts < $maxattempts) {
            $lock = $lockfactory->get_lock($resource, $progressupdatetime, $maxlifetime);
            if (!$lock) {
                $progress->progress();
                $lockattempts++;
            }
        }
        $progress->end_progress();
        return $lock;
    }
}

Filemanager

Name Type Size Permission Actions
db_record_lock_factory.php File 6.46 KB 0777
file_lock_factory.php File 5.99 KB 0777
installation_lock_factory.php File 3.34 KB 0777
lock.php File 4.33 KB 0777
lock_config.php File 3.74 KB 0777
lock_factory.php File 3.24 KB 0777
lock_utils.php File 3.1 KB 0777
mysql_lock_factory.php File 5.36 KB 0777
postgres_lock_factory.php File 8.67 KB 0777
timing_wrapper_lock_factory.php File 6.39 KB 0777
Filemanager