mirror of
https://github.com/AdguardTeam/AdGuardDNS.git
synced 2025-12-23 23:38:37 -05:00
24 lines
478 B
Go
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)
|
|
}
|