/*
    防止信令收发延迟高的时候, 用户狂点, 导致短时间触发多次信令的修改, 按照事件类型加同步锁, 即同一个事件类型仅有第一个事件生效, 多点不生效
 */
var Lock = /** @class */ (function () {
    function Lock(available) {
        this.autoUnlock = Object.create(null);
        this.locks = Object.create(null);
        this.available = false;
        this.available = available;
    }
    Lock.prototype.addLock = function (type, key) {
        var _this = this;
        if (!this.available) {
            return;
        }
        this.locks[type] = key;
        this.autoUnlock[type] = window.setTimeout(function () {
            delete _this.locks[type];
        }, 3000);
    };
    Lock.prototype.unlock = function (type, key) {
        if (!this.available) {
            return;
        }
        if (key && this.locks[type] && this.locks[type] === key) {
            window.clearTimeout(this.autoUnlock[type]);
            delete this.locks[type];
        }
    };
    Lock.prototype.isLocked = function (type) {
        if (!this.available) {
            return false;
        }
        return !!this.locks[type];
    };
    return Lock;
}());
export { Lock };
