MCPcopy Create free account
hub / github.com/getsentry/XcodeBuildMCP / acquireDaemonRegistryMutationLock

Function acquireDaemonRegistryMutationLock

src/daemon/daemon-registry.ts:39–60  ·  view source on GitHub ↗
(
  workspaceKey: string,
)

Source from the content-addressed store, hash-verified

37 * — never from request handlers.
38 */
39export function acquireDaemonRegistryMutationLock(
40 workspaceKey: string,
41): DaemonRegistryMutationLock | null {
42 const lockDir = join(getWorkspaceFilesystemLayout(workspaceKey).locks, 'daemon-registry.lock');
43 const deadline = Date.now() + DAEMON_REGISTRY_LOCK_WAIT_MS;
44 do {
45 const lock = tryAcquireFsLockSync({
46 lockDir,
47 purpose: DAEMON_REGISTRY_LOCK_PURPOSE,
48 leaseMs: DAEMON_REGISTRY_LOCK_LEASE_MS,
49 });
50 if (lock) {
51 return {
52 workspaceKey,
53 release: () => lock.release(),
54 };
55 }
56 sleepSync(DAEMON_REGISTRY_LOCK_POLL_MS);
57 } while (Date.now() < deadline);
58
59 return null;
60}
61
62/**
63 * Metadata stored for each running daemon.

Callers 4

mainFunction · 0.90
forceStopDaemonFunction · 0.90

Calls 4

tryAcquireFsLockSyncFunction · 0.90
sleepSyncFunction · 0.85
releaseMethod · 0.65

Tested by

no test coverage detected