MCPcopy Create free account
hub / github.com/HyBuildNet/quic-relay / StartCoarseClock

Function StartCoarseClock

internal/handler/context.go:18–32  ·  view source on GitHub ↗

StartCoarseClock starts a background goroutine that updates coarseTime every second. Call this once at startup before processing packets. The goroutine stops when ctx is cancelled.

(ctx context.Context)

Source from the content-addressed store, hash-verified

16// Call this once at startup before processing packets.
17// The goroutine stops when ctx is cancelled.
18func StartCoarseClock(ctx context.Context) {
19 coarseTime.Store(time.Now().Unix()) // Initialize immediately
20 go func() {
21 ticker := time.NewTicker(time.Second)
22 defer ticker.Stop()
23 for {
24 select {
25 case <-ctx.Done():
26 return
27 case <-ticker.C:
28 coarseTime.Store(time.Now().Unix())
29 }
30 }
31 }()
32}
33
34// ClientHello contains parsed TLS ClientHello data from QUIC Initial packet.
35type ClientHello struct {

Callers 1

RunMethod · 0.92

Calls 1

StopMethod · 0.45

Tested by

no test coverage detected