enter is called by WriteMessages to indicate that a new inflight operation has started, which helps synchronize with Close and ensure that the method does not return until all inflight operations were completed.
()
| 522 | // has started, which helps synchronize with Close and ensure that the method |
| 523 | // does not return until all inflight operations were completed. |
| 524 | func (w *Writer) enter() bool { |
| 525 | w.mutex.Lock() |
| 526 | defer w.mutex.Unlock() |
| 527 | if w.closed { |
| 528 | return false |
| 529 | } |
| 530 | w.group.Add(1) |
| 531 | return true |
| 532 | } |
| 533 | |
| 534 | // leave is called by WriteMessages to indicate that the inflight operation has |
| 535 | // completed. |