summaryrefslogtreecommitdiff
path: root/vendor/github.com/tetratelabs/wazero/experimental/compilationworkers.go
blob: bb76e01d3fad48677c0590257e8e24014e9c82b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package experimental

import (
	"context"

	"github.com/tetratelabs/wazero/internal/expctxkeys"
)

// WithCompilationWorkers sets the desired number of compilation workers.
func WithCompilationWorkers(ctx context.Context, workers int) context.Context {
	return context.WithValue(ctx, expctxkeys.CompilationWorkers{}, workers)
}

// GetCompilationWorkers returns the desired number of compilation workers.
// The minimum value returned is 1.
func GetCompilationWorkers(ctx context.Context) int {
	workers, _ := ctx.Value(expctxkeys.CompilationWorkers{}).(int)
	return max(workers, 1)
}