CheckInterrupt returns whether the evaluation has been interrupted.
()
| 179 | |
| 180 | // CheckInterrupt returns whether the evaluation has been interrupted. |
| 181 | func (f *ExecutionFrame) CheckInterrupt() bool { |
| 182 | if f.ctx == nil { |
| 183 | return false |
| 184 | } |
| 185 | if f.ctx.interrupted.Load() { |
| 186 | return true |
| 187 | } |
| 188 | count := f.ctx.interruptCheckCount.Add(1) |
| 189 | if f.ctx.interruptCheckFrequency > 0 && count%uint64(f.ctx.interruptCheckFrequency) == 0 { |
| 190 | select { |
| 191 | case <-f.ctx.interrupt: |
| 192 | f.ctx.interrupted.Store(true) |
| 193 | return true |
| 194 | default: |
| 195 | return false |
| 196 | } |
| 197 | } |
| 198 | return false |
| 199 | } |
| 200 | |
| 201 | // frameStack provides a synchronized pool of ExecutionFrames. |
| 202 | var frameStack = &sync.Pool{ |