%% api/shared_fence's lifetime check, step by step. sequenceDiagram participant App participant Q as Compute queue participant V as FenceEvent (value) App->>V: CreateFence(SHARED), CreateSharedHandle App->>Q: Wait(fence, 1), then Signal(other, 2) App->>V: Release fence (handle still open) Note over Q,V: queue stays blocked: other == 1 App->>V: OpenSharedHandle -> new fence, value 0 App->>V: CloseHandle Note over Q,V: still blocked: a fence is alive App->>V: Release last fence -> sweep: our handle is the only one V-->>Q: value = max, wait released Q-->>App: other == 2