Close releases the resources held by the execution frame and returns it to the pool.
()
| 102 | |
| 103 | // Close releases the resources held by the execution frame and returns it to the pool. |
| 104 | func (f *ExecutionFrame) Close() { |
| 105 | if f.parent == nil && f.ctx != nil { |
| 106 | if f.ctx.cancel != nil { |
| 107 | f.ctx.cancel() |
| 108 | f.ctx.cancel = nil |
| 109 | } |
| 110 | f.ctx.ctx = nil |
| 111 | f.ctx.interrupt = nil |
| 112 | f.ctx.state = nil |
| 113 | f.ctx.costs = nil |
| 114 | f.ctx.interrupted.Store(false) |
| 115 | f.ctx.interruptCheckCount.Store(0) |
| 116 | f.ctx.interruptCheckFrequency = 0 |
| 117 | evalContextPool.Put(f.ctx) |
| 118 | } |
| 119 | f.ctx = nil |
| 120 | f.parent = nil |
| 121 | switch a := f.Activation.(type) { |
| 122 | case *hierarchicalActivation: |
| 123 | if child, ok := a.child.(*inputActivation); ok { |
| 124 | activationInput.release(child) |
| 125 | } |
| 126 | activationStack.release(a) |
| 127 | case *inputActivation: |
| 128 | activationInput.release(a) |
| 129 | } |
| 130 | f.Activation = nil |
| 131 | frameStack.Put(f) |
| 132 | } |
| 133 | |
| 134 | // Push pushes the given activation onto the activation stack and returns the new frame. |
| 135 | // |