nuclei/pkg/js/compiler/non-pool.go

24 lines
561 B
Go
Raw Normal View History

package compiler
import (
"sync"
"github.com/dop251/goja"
2024-04-03 17:50:57 +02:00
syncutil "github.com/projectdiscovery/utils/sync"
)
var (
ephemeraljsc *syncutil.AdaptiveWaitGroup
lazyFixedSgInit = sync.OnceFunc(func() {
2024-04-03 17:50:57 +02:00
ephemeraljsc, _ = syncutil.New(syncutil.WithSize(NonPoolingVMConcurrency))
})
)
func executeWithoutPooling(p *goja.Program, args *ExecuteArgs, opts *ExecuteOptions) (result goja.Value, err error) {
lazyFixedSgInit()
ephemeraljsc.Add()
defer ephemeraljsc.Done()
runtime := createNewRuntime()
return executeWithRuntime(runtime, p, args, opts)
}