Files
AdGuardDNS/internal/cmd/runtime.go
Andrey Meshkov c1ba1c877a Sync v2.17.0
2025-11-07 13:47:40 +03:00

24 lines
478 B
Go

package cmd
import (
"context"
"log/slog"
"runtime/debug"
"github.com/AdguardTeam/golibs/logutil/slogutil"
)
// setMaxThreads sets the maximum number of threads for the Go runtime, if
// necessary. l must not be nil, n must not be negative.
func setMaxThreads(ctx context.Context, l *slog.Logger, n int) {
if n == 0 {
l.Log(ctx, slogutil.LevelTrace, "go max threads not set")
return
}
debug.SetMaxThreads(n)
l.InfoContext(ctx, "set go max threads", "n", n)
}