Add CultMeshQuicNativeRuntime.retain(): a synchronous extra reference
A caller that already holds a live runtime instance (the QUIC realtime provider, handing a reference to each newly accepted peer) needs one more reference without crossing an async boundary. `open()` itself has no I/O to await, but being `async` still forces every caller through a microtask hop; `retain()` just increments the shared refcount and returns `this`, synchronously, so the caller stays inside the same turn. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
8cf89a7e56
commit
236583c8b0
1 changed files with 13 additions and 0 deletions
|
|
@ -296,6 +296,19 @@ export class CultMeshQuicNativeRuntime {
|
|||
return CultMeshQuicNativeRuntime.shared;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes one more reference on this already-open runtime, synchronously —
|
||||
* unlike `open()`, this never awaits a runtime-open call, so a caller
|
||||
* already holding a live instance (a provider handing a reference to a
|
||||
* newly accepted peer) can attach it in the same synchronous turn instead
|
||||
* of crossing a microtask boundary that would leave the event a caller is
|
||||
* mid-dispatching unowned until the next tick.
|
||||
*/
|
||||
retain(): CultMeshQuicNativeRuntime {
|
||||
CultMeshQuicNativeRuntime.refCountValue += 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops one reference; closes the shared runtime once none remain. Refuses
|
||||
* a release when no reference is outstanding. The bridge header (section 4)
|
||||
|
|
|
|||
Loading…
Reference in a new issue