MCPcopy Create free account
hub / github.com/Hidden-Node/GooseRelayVPN-AndroidClient / idleBackoff

Function idleBackoff

internal/carrier/client.go:658–669  ·  view source on GitHub ↗

idleBackoff returns how long a worker should sleep after n consecutive no-work polls. The wake channel is selected against this timer so any new TX (kick) cancels the sleep immediately and any held server-side long-poll receives downstream chunks without needing a fresh poll — so even a 1s tail does

(n int)

Source from the content-addressed store, hash-verified

656// long-poll receives downstream chunks without needing a fresh poll —
657// so even a 1s tail does not add user-visible latency.
658func idleBackoff(n int) time.Duration {
659 switch {
660 case n < 3:
661 return pollIdleSleep
662 case n < 10:
663 return 50 * time.Millisecond
664 case n < 30:
665 return 250 * time.Millisecond
666 default:
667 return time.Second
668 }
669}
670
671// pollOnce drains pending tx frames, POSTs them as a batch, and routes any
672// response frames back to their sessions. Returns true if any work was done

Callers 2

runWorkerMethod · 0.85

Calls

no outgoing calls

Tested by 1