SetContext sets the context for the execution frame.
(ctx context.Context, interruptCheckFrequency uint)
| 96 | |
| 97 | // SetContext sets the context for the execution frame. |
| 98 | func (f *ExecutionFrame) SetContext(ctx context.Context, interruptCheckFrequency uint) error { |
| 99 | if f.parent != nil { |
| 100 | return errors.New("SetContext() called on child frame") |
| 101 | } |
| 102 | if f.ctx != nil { |
| 103 | return errors.New("SetContext() called more than once") |
| 104 | } |
| 105 | f.ctx = evalContextPool.Get().(*evalContext) |
| 106 | f.ctx.ctx, f.ctx.cancel = context.WithCancel(ctx) |
| 107 | f.ctx.asyncCalls = asyncCallStateTrackerPool.create() |
| 108 | f.ctx.gate = &asyncGate{} |
| 109 | f.ctx.interrupt = ctx.Done() |
| 110 | f.ctx.interruptCheckFrequency = interruptCheckFrequency |
| 111 | f.ctx.interruptCheckCount.Store(0) |
| 112 | f.ctx.interrupted.Store(false) |
| 113 | return nil |
| 114 | } |
| 115 | |
| 116 | // Close releases the resources held by the execution frame and returns it to the pool. |
| 117 | func (f *ExecutionFrame) Close() { |