MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / reloadRuntimeUntilStable

Function reloadRuntimeUntilStable

desktop/runtime/settings-refresh.ts:29–48  ·  view source on GitHub ↗
(input: {
  isRuntimeBusy: (runtime: PiRuntime) => boolean
  reloadRuntimeSettings: (runtimeKey: string, runtime: PiRuntime) => Promise<boolean>
  runtime: PiRuntime
  runtimeKey: string
  staleGenerations: Map<string, number>
})

Source from the content-addressed store, hash-verified

27}
28
29async function reloadRuntimeUntilStable(input: {
30 isRuntimeBusy: (runtime: PiRuntime) => boolean
31 reloadRuntimeSettings: (runtimeKey: string, runtime: PiRuntime) => Promise<boolean>
32 runtime: PiRuntime
33 runtimeKey: string
34 staleGenerations: Map<string, number>
35}) {
36 let reloaded = false
37 let reloadedGeneration: number | null = null
38 while (!input.isRuntimeBusy(input.runtime)) {
39 const generation = input.staleGenerations.get(input.runtimeKey)
40 if (generation === undefined) break
41 const didReload = await input.reloadRuntimeSettings(input.runtimeKey, input.runtime)
42 if (!didReload) break
43 reloaded = true
44 reloadedGeneration = generation
45 if (input.staleGenerations.get(input.runtimeKey) === generation) break
46 }
47 return { reloaded, reloadedGeneration }
48}
49
50async function publishReloadedComposer(input: {
51 buildComposerState: (runtime: PiRuntime) => Promise<ComposerState>

Callers 1

reloadIfSafeFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected