github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/runtime/runtimecontextmanager_noquotas.go (about) 1 //go:build noquotas 2 // +build noquotas 3 4 package runtime 5 6 import ( 7 "fmt" 8 9 "github.com/arnodel/golua/runtime/internal/luagc" 10 ) 11 12 const QuotasAvailable = false 13 14 type runtimeContextManager struct { 15 messageHandler Callable 16 parent *runtimeContextManager 17 weakRefPool luagc.Pool 18 } 19 20 var _ RuntimeContext = (*runtimeContextManager)(nil) 21 22 func (m *runtimeContextManager) initRoot() { 23 m.weakRefPool = luagc.NewDefaultPool() 24 } 25 26 func (m *runtimeContextManager) HardLimits() (r RuntimeResources) { 27 return 28 } 29 30 func (m *runtimeContextManager) SoftLimits() (r RuntimeResources) { 31 return 32 } 33 34 func (m *runtimeContextManager) UsedResources() (r RuntimeResources) { 35 return 36 } 37 38 func (m *runtimeContextManager) setStatus(RuntimeContextStatus) { 39 } 40 41 func (m *runtimeContextManager) Status() RuntimeContextStatus { 42 return StatusLive 43 } 44 45 func (m *runtimeContextManager) RequiredFlags() (f ComplianceFlags) { 46 return 47 } 48 49 func (m *runtimeContextManager) CheckRequiredFlags(ComplianceFlags) error { 50 return nil 51 } 52 53 func (m *runtimeContextManager) Parent() RuntimeContext { 54 return nil 55 } 56 57 func (m *runtimeContextManager) Due() bool { 58 return false 59 } 60 61 func (m *runtimeContextManager) SetStopLevel(StopLevel) { 62 } 63 64 func (m *runtimeContextManager) GCPolicy() GCPolicy { 65 return ShareGCPolicy 66 } 67 68 func (m *runtimeContextManager) RuntimeContext() RuntimeContext { 69 return m 70 } 71 72 func (m *runtimeContextManager) PushContext(ctx RuntimeContextDef) { 73 parent := *m 74 m.messageHandler = ctx.MessageHandler 75 m.parent = &parent 76 } 77 78 func (m *runtimeContextManager) PopContext() RuntimeContext { 79 if m == nil || m.parent == nil { 80 return nil 81 } 82 mCopy := *m 83 *m = *m.parent 84 return &mCopy 85 } 86 87 func (m *runtimeContextManager) CallContext(def RuntimeContextDef, f func() error) (ctx RuntimeContext, err error) { 88 m.PushContext(def) 89 defer m.PopContext() 90 return nil, f() 91 } 92 93 func (m *runtimeContextManager) RequireCPU(cpuAmount uint64) { 94 } 95 96 func (m *runtimeContextManager) UnusedCPU() uint64 { 97 return 0 98 } 99 100 func (m *runtimeContextManager) RequireMem(memAmount uint64) { 101 } 102 103 func (m *runtimeContextManager) RequireSize(sz uintptr) uint64 { 104 return 0 105 } 106 107 func (m *runtimeContextManager) RequireArrSize(sz uintptr, n int) uint64 { 108 return 0 109 } 110 111 func (m *runtimeContextManager) RequireBytes(n int) uint64 { 112 return 0 113 } 114 115 func (m *runtimeContextManager) ReleaseMem(memAmount uint64) { 116 } 117 118 func (m *runtimeContextManager) ReleaseSize(sz uintptr) { 119 } 120 121 func (m *runtimeContextManager) ReleaseArrSize(sz uintptr, n int) { 122 } 123 124 func (m *runtimeContextManager) ReleaseBytes(n int) { 125 } 126 127 func (m *runtimeContextManager) UnusedMem() uint64 { 128 return 0 129 } 130 131 func (m *runtimeContextManager) LinearUnused(cpuFactor uint64) uint64 { 132 return 0 133 } 134 135 func (m *runtimeContextManager) LinearRequire(cpuFactor uint64, amt uint64) { 136 } 137 138 func (m *runtimeContextManager) ResetQuota() { 139 } 140 141 func (m *runtimeContextManager) TerminateContext(format string, args ...interface{}) { 142 // I don't know if it should do it? 143 panic(ContextTerminationError{ 144 message: fmt.Sprintf(format, args...), 145 }) 146 }