resolveVM returns the *VM that owns the given otto runtime. Forks share a single vms map, so reads must be guarded against concurrent Fork/Dispose writes happening on other VMs of the same family.
(o *otto.Otto)
| 87 | // single vms map, so reads must be guarded against concurrent Fork/Dispose |
| 88 | // writes happening on other VMs of the same family. |
| 89 | func (v *VM) resolveVM(o *otto.Otto) *VM { |
| 90 | v.vmsMu.RLock() |
| 91 | defer v.vmsMu.RUnlock() |
| 92 | return v.vms[o] |
| 93 | } |
| 94 | |
| 95 | // Run runs code with this VM. Run can NOT be executed concurrency |
| 96 | func (v *VM) Run(ctx context.Context, code any) (*Value, error) { |