<commit_before><?php
/**
 * Pimcore
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.pimcore.org/license
 *
 * @category   Pimcore
 * @package    Document
 * @copyright  Copyright (c) 2009-2010 elements.at New Media Solutions GmbH (http://www.elements.at)
 * @license    http://www.pimcore.org/license     New BSD License
 */

class Tool_Lock extends Pimcore_Model_Abstract {

    /**
     * @var array
     */
    protected static $acquiredLocks = array();

    /**
     * @var Tool_Lock
     */
    protected static $instance;

    /**
     * @return Tool_Lock
     */
    protected static function getInstance () {
        if(!self::$instance) {
            self::$instance = new self();
        }

        return self::$instance;
    }

    /**
     * @param $key
     */
    public static function acquire ($key) {
        $instance = self::getInstance();
        $instance->getResource()->acquire($key);

        self::$acquiredLocks[$key] = $key;
    }

    /**
     * @param $key
     */
    public static function release ($key) {
        $instance = self::getInstance();
        $instance->getResource()->release($key);

        unset(self::$acquiredLocks[$key]);
    }

    /**
     *
     */
    public static function releaseAll() {
        $locks = self::$acquiredLocks;

        Logger::debug($locks);

        foreach($locks as $key) {
            self::release($key);
        }
    }
}
<commit_msg>Tool_Lock: added isLocked static method<commit_after><?php
/**
 * Pimcore
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.pimcore.org/license
 *
 * @category   Pimcore
 * @package    Document
 * @copyright  Copyright (c) 2009-2010 elements.at New Media Solutions GmbH (http://www.elements.at)
 * @license    http://www.pimcore.org/license     New BSD License
 */

class Tool_Lock extends Pimcore_Model_Abstract {

    /**
     * @var array
     */
    protected static $acquiredLocks = array();

    /**
     * @var Tool_Lock
     */
    protected static $instance;

    /**
     * @return Tool_Lock
     */
    protected static function getInstance () {
        if(!self::$instance) {
            self::$instance = new self();
        }

        return self::$instance;
    }

    /**
     * @param string $key
     */
    public static function acquire ($key) {
        $instance = self::getInstance();
        $instance->getResource()->acquire($key);

        self::$acquiredLocks[$key] = $key;
    }

    /**
     * @param string $key
     */
    public static function release ($key) {
        $instance = self::getInstance();
        $instance->getResource()->release($key);

        unset(self::$acquiredLocks[$key]);
    }

    /**
     * @param string $key
     * @return bool
     */
    public static function isLocked ($key) {
        $instance = self::getInstance();
        return $instance->getResource()->isLocked($key);
    }

    /**
     *
     */
    public static function releaseAll() {
        $locks = self::$acquiredLocks;

        Logger::debug($locks);

        foreach($locks as $key) {
            self::release($key);
        }
    }
}

{'fraction_non_alphanumeric': 0.13423195731536086, 'fraction_numerical': 0.004493119910137602, 'mean_word_length': 1.9077551020408163, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4911168', 'n_tokens_mistral': 1082, 'n_tokens_neox': 987, 'n_words': 248}