Documentation ¶
Overview ¶
Package maxprocs lets Go programs easily configure runtime.GOMAXPROCS to match the configured Linux CPU quota. Unlike the top-level automaxprocs package, it lets the caller configure logging and handle errors.
Example ¶
package main import ( "log" "go.uber.org/automaxprocs/maxprocs" ) func main() { undo, err := maxprocs.Set() defer undo() if err != nil { log.Fatalf("failed to set GOMAXPROCS: %v", err) } // Insert your application logic here. }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const Version = "1.6.0"
Version is the current package version.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option alters the behavior of Set.
func Logger ¶
Logger uses the supplied printf implementation for log output. By default, Set doesn't log anything.
Example ¶
package main import ( "log" "go.uber.org/automaxprocs/maxprocs" ) func main() { // By default, Set doesn't output any logs. You can enable logging by // supplying a printf implementation. undo, err := maxprocs.Set(maxprocs.Logger(log.Printf)) defer undo() if err != nil { log.Fatalf("failed to set GOMAXPROCS: %v", err) } }
Output:
func Min ¶ added in v1.1.0
Min sets the minimum GOMAXPROCS value that will be used. Any value below 1 is ignored.
func RoundQuotaFunc ¶ added in v1.6.0
RoundQuotaFunc sets the function that will be used to covert the CPU quota from float to int.
Click to show internal directories.
Click to hide internal directories.