Close releases the resources held by the execution frame and returns it to the pool.
()
| 115 | |
| 116 | // Close releases the resources held by the execution frame and returns it to the pool. |
| 117 | func (f *ExecutionFrame) Close() { |
| 118 | if f.parent == nil && f.ctx != nil { |
| 119 | if f.ctx.cancel != nil { |
| 120 | f.ctx.cancel() |
| 121 | f.ctx.cancel = nil |
| 122 | } |
| 123 | f.ctx.ctx = nil |
| 124 | f.ctx.gate = nil |
| 125 | asyncCallStateTrackerPool.release(f.ctx.asyncCalls) |
| 126 | f.ctx.asyncCalls = nil |
| 127 | f.ctx.observer = nil |
| 128 | f.ctx.interrupt = nil |
| 129 | f.ctx.state = nil |
| 130 | f.ctx.costs = nil |
| 131 | f.ctx.interrupted.Store(false) |
| 132 | f.ctx.interruptCheckCount.Store(0) |
| 133 | f.ctx.interruptCheckFrequency = 0 |
| 134 | evalContextPool.Put(f.ctx) |
| 135 | } |
| 136 | f.ctx = nil |
| 137 | f.parent = nil |
| 138 | if f.Activation != nil { |
| 139 | switch a := f.Activation.(type) { |
| 140 | case *hierarchicalActivation: |
| 141 | if child, ok := a.child.(*inputActivation); ok { |
| 142 | activationInput.release(child) |
| 143 | } |
| 144 | activationStack.release(a) |
| 145 | case *inputActivation: |
| 146 | activationInput.release(a) |
| 147 | } |
| 148 | f.Activation = nil |
| 149 | frameStack.Put(f) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // Push pushes the given activation onto the activation stack and returns the new frame. |
| 154 | // |