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