newPool creates a new pool with pre-warmed vms generated from the specified factory.
(size int, factory func() *goja.Runtime)
| 20 | |
| 21 | // newPool creates a new pool with pre-warmed vms generated from the specified factory. |
| 22 | func newPool(size int, factory func() *goja.Runtime) *vmsPool { |
| 23 | pool := &vmsPool{ |
| 24 | factory: factory, |
| 25 | items: make([]*poolItem, size), |
| 26 | } |
| 27 | |
| 28 | for i := 0; i < size; i++ { |
| 29 | vm := pool.factory() |
| 30 | pool.items[i] = &poolItem{vm: vm} |
| 31 | } |
| 32 | |
| 33 | return pool |
| 34 | } |
| 35 | |
| 36 | // run executes "call" with a vm created from the pool |
| 37 | // (either from the buffer or a new one if all buffered vms are busy) |
no outgoing calls
searching dependent graphs…