mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 15:27:43 +00:00
4.31.0
* Added: Option for displaying larger embeds in chat for supported sources. This won't do anything until the link service is updated with support. * Added: Support for v6 rich content for embeds, tool-tips, and the rich content debugger. * Changed: Limit the width of rich content embeds in portrait mode. * Fixed: Clicking badges not working correctly. * Fixed: Rich embeds being rendered when an unsupported version is returned from the embed server. * Fixed: The month being off by one in the default filename when saving a settings backup. * Fixed: The Chat Identity entry not appearing in the chat settings menu when appropriate. * API Added: `Mutex()` class for limiting something to a certain number of accessors at once.
This commit is contained in:
parent
97c96be276
commit
e704677e84
14 changed files with 228 additions and 104 deletions
|
@ -94,6 +94,39 @@ export function timeout(promise, delay) {
|
|||
}
|
||||
|
||||
|
||||
export class Mutex {
|
||||
constructor(limit = 1) {
|
||||
this.limit = limit;
|
||||
this._active = 0;
|
||||
this._waiting = [];
|
||||
|
||||
this._done = this._done.bind(this);
|
||||
}
|
||||
|
||||
get available() { return this._active < this.limit }
|
||||
|
||||
_done() {
|
||||
this._active--;
|
||||
|
||||
while(this._active < this.limit && this._waiting.length > 0) {
|
||||
this._active++;
|
||||
const waiter = this._waiting.shift();
|
||||
waiter(this._done);
|
||||
}
|
||||
}
|
||||
|
||||
wait() {
|
||||
if ( this._active < this.limit) {
|
||||
this._active++;
|
||||
return Promise.resolve(this._done);
|
||||
}
|
||||
|
||||
return new Promise(s => this._waiting.push(s));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a wrapper for a function that will only execute the function
|
||||
* a period of time after it has stopped being called.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue