Working setup

This commit is contained in:
Andras Schmelczer 2026-01-12 21:24:05 +00:00
parent e3a90833ff
commit 2dfb8b71e5
16 changed files with 459 additions and 318 deletions

View file

@ -18,7 +18,7 @@ export class Locks<T> {
[() => unknown, (err: unknown) => unknown][]
>();
public constructor(private readonly logger?: Logger) {}
public constructor(private readonly logger?: Logger) { }
/**
* Executes a function while holding exclusive locks on one or more keys.
@ -125,6 +125,18 @@ export class Locks<T> {
});
}
/**
* Waits until a lock is released without acquiring it.
* Operations are queued in FIFO order.
*
* @param key The key to wait for
* @returns Promise that resolves when lock is released
*/
public async waitForLockWithoutAcquiringLock(key: T): Promise<void> {
await this.waitForLock(key);
this.unlock(key);
}
/**
* Releases a lock and grants access to the next waiting operation in FIFO order.
* Removes the key from locked set if no waiters.

View file

@ -1,9 +1,8 @@
import type { SyncClient } from "../../sync-client";
import type { LogLine } from "../../tracing/logger";
import type { Logger, LogLine } from "../../tracing/logger";
import { LogLevel } from "../../tracing/logger";
export function logToConsole(client: SyncClient): void {
client.logger.onLogEmitted.add((logLine: LogLine) => {
export function logToConsole(logger: Logger): void {
logger.onLogEmitted.add((logLine: LogLine) => {
const formatted = `${logLine.timestamp.toISOString()} ${logLine.level} ${logLine.message}`;
switch (logLine.level) {