CheckInterrupt returns whether the evaluation has been interrupted.
()
| 350 | |
| 351 | // CheckInterrupt returns whether the evaluation has been interrupted. |
| 352 | func (f *ExecutionFrame) CheckInterrupt() bool { |
| 353 | if f.ctx == nil { |
| 354 | return false |
| 355 | } |
| 356 | if f.ctx.interrupted.Load() { |
| 357 | return true |
| 358 | } |
| 359 | count := f.ctx.interruptCheckCount.Add(1) |
| 360 | if f.ctx.interruptCheckFrequency > 0 && count%uint64(f.ctx.interruptCheckFrequency) == 0 { |
| 361 | select { |
| 362 | case <-f.ctx.interrupt: |
| 363 | f.ctx.interrupted.Store(true) |
| 364 | return true |
| 365 | default: |
| 366 | return false |
| 367 | } |
| 368 | } |
| 369 | return false |
| 370 | } |
| 371 | |
| 372 | // CostTracker returns the active CostTracker for this evaluation pass, or nil. |
| 373 | func (f *ExecutionFrame) CostTracker() *CostTracker { |