Merge branch 'develop' into fix-7311

This commit is contained in:
かっこかり 2024-06-09 18:49:59 +09:00 committed by GitHub
commit a5424f4134
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
120 changed files with 7910 additions and 596 deletions

View file

@ -7,3 +7,13 @@ export async function tick(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
await new Promise((globalThis.requestIdleCallback ?? setTimeout) as never);
}
/**
* @see https://github.com/misskey-dev/misskey/issues/11267
*/
export function semaphore(counter = 0, waiting: (() => void)[] = []) {
return {
acquire: () => ++counter > 1 && new Promise<void>(resolve => waiting.push(resolve)),
release: () => --counter && waiting.pop()?.(),
};
}