Complete releases a concurrency slot and notifies completions.
(ctx context.Context, callID int64)
| 509 | |
| 510 | // Complete releases a concurrency slot and notifies completions. |
| 511 | func (g *asyncGate) Complete(ctx context.Context, callID int64) { |
| 512 | if g == nil { |
| 513 | return |
| 514 | } |
| 515 | g.Release() |
| 516 | |
| 517 | if g.completions != nil { |
| 518 | // Prioritize context cancellation to prevent racy completion signals. |
| 519 | if ctx.Err() != nil { |
| 520 | return |
| 521 | } |
| 522 | select { |
| 523 | case g.completions <- callID: |
| 524 | case <-ctx.Done(): |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | // ActiveCalls returns the number of active asynchronous calls. |
| 530 | func (g *asyncGate) ActiveCalls() int { |