SetContext sets the context for the execution frame.
(ctx context.Context, interruptCheckFrequency uint)
| 156 | |
| 157 | // SetContext sets the context for the execution frame. |
| 158 | func (f *ExecutionFrame) SetContext(ctx context.Context, interruptCheckFrequency uint) error { |
| 159 | if f.parent != nil { |
| 160 | return errors.New("SetContext() called on child frame") |
| 161 | } |
| 162 | if f.ctx != nil { |
| 163 | return errors.New("SetContext() called more than once") |
| 164 | } |
| 165 | f.ctx = evalContextPool.Get().(*evalContext) |
| 166 | f.ctx.ctx, f.ctx.cancel = context.WithCancel(ctx) |
| 167 | f.ctx.asyncCalls = asyncCallStateTrackerPool.create() |
| 168 | f.ctx.gate = &asyncGate{} |
| 169 | f.ctx.interrupt = ctx.Done() |
| 170 | f.ctx.interruptCheckFrequency = interruptCheckFrequency |
| 171 | f.ctx.interruptCheckCount.Store(0) |
| 172 | f.ctx.interrupted.Store(false) |
| 173 | return nil |
| 174 | } |
| 175 | |
| 176 | // Close releases the resources held by the execution frame and returns it to the pool. |
| 177 | func (f *ExecutionFrame) Close() { |