CheckInterrupt returns whether the evaluation has been interrupted.
()
| 212 | |
| 213 | // CheckInterrupt returns whether the evaluation has been interrupted. |
| 214 | func (f *ExecutionFrame) CheckInterrupt() bool { |
| 215 | if f.ctx == nil { |
| 216 | return false |
| 217 | } |
| 218 | if f.ctx.interrupted.Load() { |
| 219 | return true |
| 220 | } |
| 221 | count := f.ctx.interruptCheckCount.Add(1) |
| 222 | if f.ctx.interruptCheckFrequency > 0 && count%uint64(f.ctx.interruptCheckFrequency) == 0 { |
| 223 | select { |
| 224 | case <-f.ctx.interrupt: |
| 225 | f.ctx.interrupted.Store(true) |
| 226 | return true |
| 227 | default: |
| 228 | return false |
| 229 | } |
| 230 | } |
| 231 | return false |
| 232 | } |
| 233 | |
| 234 | // ComputeResult tracks and computes the result of the given asynchronous function. |
| 235 | // |