forked from quic-issues/427e7578-d7bf-49c8-aee9-2dd999e25316
implemented frontend including separate message system; started to implement backend
This commit is contained in:
54
yjs-poll/node_modules/lib0/dist/mutex-63f09c81.cjs
generated
vendored
Normal file
54
yjs-poll/node_modules/lib0/dist/mutex-63f09c81.cjs
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Mutual exclude for JavaScript.
|
||||
*
|
||||
* @module mutex
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback mutex
|
||||
* @param {function():void} cb Only executed when this mutex is not in the current stack
|
||||
* @param {function():void} [elseCb] Executed when this mutex is in the current stack
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a mutual exclude function with the following property:
|
||||
*
|
||||
* ```js
|
||||
* const mutex = createMutex()
|
||||
* mutex(() => {
|
||||
* // This function is immediately executed
|
||||
* mutex(() => {
|
||||
* // This function is not executed, as the mutex is already active.
|
||||
* })
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* @return {mutex} A mutual exclude function
|
||||
* @public
|
||||
*/
|
||||
const createMutex = () => {
|
||||
let token = true;
|
||||
return (f, g) => {
|
||||
if (token) {
|
||||
token = false;
|
||||
try {
|
||||
f();
|
||||
} finally {
|
||||
token = true;
|
||||
}
|
||||
} else if (g !== undefined) {
|
||||
g();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var mutex = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
createMutex: createMutex
|
||||
});
|
||||
|
||||
exports.createMutex = createMutex;
|
||||
exports.mutex = mutex;
|
||||
//# sourceMappingURL=mutex-63f09c81.cjs.map
|
||||
Reference in New Issue
Block a user