| 123456789101112131415161718192021222324252627282930313233343536 |
- /**
- * DevExtreme (core/utils/locker.js)
- * Version: 19.1.16
- * Build date: Tue Oct 18 2022
- *
- * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
- * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
- */
- "use strict";
- var errors = require("../errors");
- var Locker = function() {
- var info = {};
- var currentCount = function(lockName) {
- return info[lockName] || 0
- };
- return {
- obtain: function(lockName) {
- info[lockName] = currentCount(lockName) + 1
- },
- release: function(lockName) {
- var count = currentCount(lockName);
- if (count < 1) {
- throw errors.Error("E0014")
- }
- if (1 === count) {
- delete info[lockName]
- } else {
- info[lockName] = count - 1
- }
- },
- locked: function(lockName) {
- return currentCount(lockName) > 0
- }
- }
- };
- module.exports = Locker;
|