MCPcopy Create free account
hub / github.com/evilsocket/sum / CreateExecutionPool

Function CreateExecutionPool

service/compiled_exec_pool.go:37–58  ·  view source on GitHub ↗

CreateExecutionPool creates an ExecutionPool object for the given VM.

(vm *otto.Otto)

Source from the content-addressed store, hash-verified

35
36// CreateExecutionPool creates an ExecutionPool object for the given VM.
37func CreateExecutionPool(vm *otto.Otto) *ExecutionPool {
38 p := &ExecutionPool{
39 root: vm,
40 clones: make([]*VM, numVMInPool),
41 freeList: make([]int, numVMInPool),
42 freeWay: make(chan int, numVMInPool),
43 }
44
45 for i := 0; i < numVMInPool; i++ {
46 p.freeList[i] = i
47 p.clones[i] = &VM{
48 Otto: p.root.Copy(),
49 parent: p,
50 index: i,
51 }
52 // presignal a free object so the very first
53 // loop won't wait
54 p.freeWay <- i
55 }
56
57 return p
58}
59
60func (p *ExecutionPool) setFree(index int) {
61 p.freeWay <- index

Callers 1

compileFunction · 0.85

Calls 1

CopyMethod · 0.65

Tested by

no test coverage detected