MCPcopy
hub / github.com/thrasher-corp/gocryptotrader / New

Method New

gctscript/vm/gctscript.go:13–29  ·  view source on GitHub ↗

New returns a new instance of VM

()

Source from the content-addressed store, hash-verified

11
12// New returns a new instance of VM
13func (g *GctScriptManager) New() *VM {
14 if VMSCount.Len() >= g.GetMaxVirtualMachines() {
15 if g.config.Verbose {
16 log.Warnf(log.GCTScriptMgr, "GCTScript MaxVirtualMachines (%v) hit, unable to start further instances",
17 g.GetMaxVirtualMachines())
18 }
19 return nil
20 }
21 VMSCount.add()
22 vm := g.NewVM()
23 if vm == nil {
24 VMSCount.remove()
25 } else {
26 AllVMSync.Store(vm.ID, vm)
27 }
28 return vm
29}
30
31// Validate will attempt to execute a script in a test/non-live environment
32// to confirm it passes requirements for execution

Callers 15

TestNewVMFunction · 0.95
TestVMLoadFunction · 0.95
TestVMLoad1sFunction · 0.95
TestVMLoadNegativeTimerFunction · 0.95
TestVMLoadNilVMFunction · 0.95
TestCompileAndRunNilVMFunction · 0.95
TestVMLoadNoFileFunction · 0.95
TestVMCompileFunction · 0.95
TestVMWithRunnerFunction · 0.95
TestVMWithRunnerOnceFunction · 0.95

Calls 7

GetMaxVirtualMachinesMethod · 0.95
NewVMMethod · 0.95
WarnfFunction · 0.92
removeMethod · 0.80
StoreMethod · 0.80
LenMethod · 0.45
addMethod · 0.45

Tested by 15

TestNewVMFunction · 0.76
TestVMLoadFunction · 0.76
TestVMLoad1sFunction · 0.76
TestVMLoadNegativeTimerFunction · 0.76
TestVMLoadNilVMFunction · 0.76
TestCompileAndRunNilVMFunction · 0.76
TestVMLoadNoFileFunction · 0.76
TestVMCompileFunction · 0.76
TestVMWithRunnerFunction · 0.76
TestVMWithRunnerOnceFunction · 0.76